简体   繁体   中英

how can i saved more than one check box on one column

i have this code :

<table width="100%" border="0" id="SpecialReq1"> 
  <tr>   
    <td width="100px"><input type="checkbox" name="txtSpecialReq" id="txtSpecialReq" value="Non-Smookong" class="checkox">Non-Smookong</td>
    <td width="100px"><input type="checkbox" name="txtSpecialReq" id="txtSpecialReq" value="Smooking-Room" class="checkox">Smooking Room</td>
    <td width="100px"><input type="checkbox" name="txtSpecialReq" id="txtSpecialReq" value="Quiet-Room" class="checkox">Quiet Room</td>
    <td width="100px"><input type="checkbox" name="txtSpecialReq" id="txtSpecialReq" value="Parking" class="checkox">Parking</td>
    <td width="100px"><input type="checkbox" name="txtSpecialReq" id="txtSpecialReq" value="Early-Arrival" class="checkox">Early Arrival</td>
  </tr>
</table> 

this code to check which i need to save on table , my problem is i canot save more than one check box on one record , so i need to save more than one on on column on table on database, and how can i display it ??

Change the name to name="txtSpecialReq[]" on each checkbox.

Then once you submit the form the items will be in an array as $_POST[txtSpecialReq] .

// output all items in the array
foreach($_POST['txtSpecialReq'] as $value) {
    echo $value;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM