Adding a form array to MySQL using PHP -
i cannot array put mysql database in format 'arrayitem1,arrayitem2,etc...'
here's forms are:
<form action="http://www.nccskills.co.uk/bookings/process.php" method="post" name="bookingform"> <div id="row12"> <div class="col1"> <input type="checkbox" name="voccheck[]" value="hasa"> health , safety awareness </div> <div class="col2"> <input type="checkbox" name="voccheck[]" value="ead"> equality , diversity </div> </div> <div id="row13"> <div class="col1"> <input type="checkbox" name="voccheck[]" value="ecc"> effective customer care </div> <div class="col2"> <input type="checkbox" name="voccheck[]" value="cc"> care certificate</div> </div>
what php use achieve this?
thanks in advance.
in process.php
file want have code looks this:
//create connection using mysqli $conn = new mysqli($servername, $username, $password, $dbname); //prepare statement. $conn->prepare('insert tablename(fieldname) values(?)'); //put checkboxes together, if selected. $checked = ''; if(is_array($_post['voccheck'])) { $checked = implode(',', $_post['voccheck']); } //bind value. $conn->bind_param('s', $checked); //execute question. $conn->execute();
not 100% sure need check if $_post['voccheck']
array , cant try right included on safe side. might want throw error handling in case connection doesn't work etc. useful links you:
Comments
Post a Comment