post problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
valen53
Forum Contributor
Posts: 137
Joined: Tue Aug 27, 2002 9:29 am

post problem

Post 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
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post 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.
valen53
Forum Contributor
Posts: 137
Joined: Tue Aug 27, 2002 9:29 am

Post 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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply