Page 1 of 1

post problem

Posted: Tue Sep 10, 2002 12:34 pm
by valen53
i do a reservation system now, it can be cancel the order. so each time member login, their order will be display. The problem is that the page display few order, but i only want to delete a order. so i put the code as below:
<tr bgcolor="#FFCC66">
<td>'.$from.'</td>
<td>'.$to.'</td>
<td>'.$date.'</td>
<td>'.$time.'</td>
<td>'.$odate.'</td>
<td>'.$seatno.'</td>
<td>RM'.$total.'</td>
<input type="checkbox" name="checkbox" value="checkbox">
<td><input name="Cancel" type="submit"id="Cancel" value="'.$count.'">
when i tick the checkbox, a order will be deleted. But the problem is i dunno how to verify that order is belong to that checkbox. so i can't delete it. hope anyone can help me ? thank u

Posted: Tue Sep 10, 2002 4:39 pm
by Takuma
change the name property for that checkbox like

Code: Select all

&lt;input type="checkbox" name="hello" value="checkbox"&gt;
on the page your processing this data just do this

Code: Select all

&lt;?php
echo $_POST&#1111;"hello"];
?&gt;
It'll say "checkbox" if checkbox was checked if not nothing.

Posted: Wed Sep 11, 2002 1:56 am
by valen53
Takuma wrote:change the name property for that checkbox like

Code: Select all

&lt;input type="checkbox" name="hello" value="checkbox"&gt;
on the page your processing this data just do this

Code: Select all

&lt;?php
echo $_POST&#1111;"hello"];
?&gt;
Thank ur reply, but how about other field? how to post them? b'cos system doesn't recognise the other field is below that checked box.

Posted: Wed Sep 11, 2002 2:09 am
by twigletmac
You have to give the checkbox some information as to what to delete, for example an order id - a number or code that is unique to each order:

Code: Select all

echo '&lt;input type="checkbox" name="delete_order&#1111;]" value="'.$orderID.'" /&gt;';
if you name the checkbox next to each record delete_order[] then you can loop through it using something like:

Code: Select all

if (isset($_POST&#1111;'delete_order']) {
    foreach ($_POST&#1111;'delete_order'] as $value) {
        $sql = "DELETE FROM orders_table WHERE orderID = '$value'";
        @mysql_query($sql) or die(mysql_error());
    }
}
but you do need a unique identifier for each record.

Mac