I have a form that has mutiple checkboxes with the name itm This obviously stores all checked values into the array $_POST['itm'][]
My question is I want the values of the array stored in the relevant column in the format 1:88:99:77: The : is the separator and the digits are the checkbox values
However when I submit my form it just displays Array() I then tried the serialize() function.. not what I want at all
So can anyone help please
Code Below``
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$forname = $_POST['forename'];
$surname = $_POST['surname'];
$newfname = str_replace("'","",$_POST['forename']);
$newsname = str_replace("'","",$_POST['surname']);
$year = date('y');
$month = date('m');
$day = date('d');
$username = $newfname.$newsname.$month.$year;
// Perform queries
$addq = mysqli_query($con,"INSERT INTO `workshop-jobs` (wsjid, wscid, wsccid, summary, jobtype, caterhamwarrantyid, worktobedone, quoteinvref, datearrived, workstartdate, workstarttime, workfinishdate, hours, reqbydate, technician, status, completed, invoiced, notes)
VALUES ('','$_POST[wscid]','$_POST[wsccid]','$_POST[summary]','$_POST[jobtype]','$_POST[caterhamwarrantyid]','$_POST['itm']','$quoteinvref','$_POST[datearrived]','$_POST[workstartdate]','$_POST[workstarttime]','$_POST[workfinishdate]','0','$_POST[reqbydate]','$_POST[technician]','$_POST[status]','0','0','$_POST[notes]')");
if($addq){
$last_id = $con->insert_id;
$lastid = mysqli_query($con,"SELECT * FROM `users` WHERE userid = '$last_id'");
$lastidr = mysqli_fetch_assoc($lastid);
header("Location: addjobbat.php?wscid=$last_id");
}
echo mysqli_error($con);
mysqli_close($con);
Form Code
<div class="panel-body">
<input name="itm[]" class="serviceitem" type="checkbox" value="1:">
1000 / 3 Month Service ( Sigma / Duratec / CSR )<br>
<input name="itm[]" class="serviceitem" type="checkbox" value="2:">
1000 / 3 Month 620 Service<br>
<input name="itm[]" class="serviceitem" type="checkbox" value="3:">
Annual Service ONE ( Sigma / Duratec / CSR )<br>
<input name="itm[]" class="serviceitem" type="checkbox" value="4:">
Annual Service ONE ( Duratec R500 )<br>
<input name="itm[]" class="serviceitem" type="checkbox" value="5:">
620 Annual Service ONE<br>
<input name="itm[]" class="serviceitem" type="checkbox" value="6:">
Annual Service TWO ( Sigma / Duratec / CSR )<br>
<input name="itm[]" class="serviceitem" type="checkbox" value="7:">
620 Annual Service TWO<br>
<input name="itm[]" class="serviceitem" type="checkbox" value="8:">
4 year add on (Sigma / Duratec / CSR)<br>
<input name="itm[]" class="serviceitem" type="checkbox" value="9:">
6 year add on (Sigma / Duratec / CSR)<br>
<input name="itm[]" class="serviceitem" type="checkbox" value="10:">
500 Mile Service ( K-Series )<br>
<input name="itm[]" class="serviceitem" type="checkbox" value="11:">
3000 Mile Service ( K-Series )<br>
<input name="itm[]" class="serviceitem" type="checkbox" value="12:">
6000 Mile Service ( K-Series ) <br>
<input name="itm[]" class="serviceitem" type="checkbox" value="13:">
12000 Mile Service ( K-Series )<br>
<input name="itm[]" class="serviceitem" type="checkbox" value="14:">
24000 Mile Service ( K-Series )<br>
<input name="itm[]" class="serviceitem" type="checkbox" value="15:">
Race Car Service ( All Models )<br>
<input name="itm[]" class="serviceitem" type="checkbox" value="16:">
Suzuki 160 1st Service<br>
<input name="itm[]" class="serviceitem" type="checkbox" value="17:">
Suzuki 2 Year Addon<br>
<input name="itm[]" class="serviceitem" type="checkbox" value="18:">
Suzuki 3000 Mile Service<br>
<input name="itm[]" class="serviceitem" type="checkbox" value="19:">
Suzuki 4 Year Addon<br>
<input name="itm[]" class="serviceitem" type="checkbox" value="20:">
Suzuki 6000 Mile Service<br>
<input name="itm[]" class="serviceitem" type="checkbox" value="21:">
Suzuki 6 Year Addon<br>
</div>