View Single Post
Old 05-30-2011, 10:45 PM   #1 (permalink)
destroyerx15
The Wanderer
 
Join Date: May 2011
Posts: 9
Thanks: 0
destroyerx15 is on a distinguished road
Default work with multi cheek box to same row

hi guys
i need some help to insert multi cheek box to db in one row.

i make like this
in form.html

<table class="table">
<form action="1.php" method="post">
<tr>


<th class="th">ORDER_DESC </th>

</tr>
<tr>
<td class="td"><input type="checkbox" name="checkbox[]" value="CSF"/> CSF </td>
</tr>

<tr>
<td class="td"><input type="checkbox" name="checkbox[]" value="LFT"/> LFT </td>
</tr>

<tr>
<td class="td"><input type="checkbox" name="checkbox[]" value="RFR"/> RFR </td>
</tr>

<tr>
<td class="td" ><input type="submit" value="Submit" name="Submit"/>
</td>
</tr>
</form>
</table>


in php:

<?php
$orders = $_POST['checkbox'];
mysql_connect("localhost", "root","") or die ('Error: '. mysql_error());
mysql_select_db("project");

if(count($orders)>0)
{
foreach($orders as $key=>$order)
{
$query="INSERT INTO orders (ORDER_DESC) VALUES ('".$order."' )";
mysql_query($query) or die ('Error Updating the Database' . mysql_errno());
}
echo "Order Successfully Placed";
}
else
echo "No Orders";
?>

when i press submit it insert into data but not in one row

can help ?
destroyerx15 is offline  
Reply With Quote