case 'delete':
if ($cart) {
$items = explode(',',$cart);
$newcart = '';
foreach ($items as $item) {
if ($_GET['id'] != $item) {
if ($newcart != '') {
$newcart .= ','.$item;
} else {
$newcart = $item;
}
}
}
$cart = $newcart;
}
Delete from database upon action selected
Page 1 of 13 Replies - 188 Views - Last Post: 02 August 2012 - 09:31 AM
#1
Delete from database upon action selected
Posted 02 August 2012 - 08:52 AM
Anyone know what to write to delete the whole row of particular id at datbase
Replies To: Delete from database upon action selected
#2
Re: Delete from database upon action selected
Posted 02 August 2012 - 08:55 AM
Deleting from the database is a lot more dangerous than marking items as non-active. But if you must, you shouldn't EVER plug GET array variables into your sql string. But if you must do that, you can use the following :
delete from table_name where id='$_GET[id]';
Though I would recommend you learn from the provided statement, & do it safely & correctly.
delete from table_name where id='$_GET[id]';
Though I would recommend you learn from the provided statement, & do it safely & correctly.
#3
Re: Delete from database upon action selected
Posted 02 August 2012 - 09:03 AM
so how do i use that in the following codes?
<td><?echo '<br /><a href="cart.php?action=delete&id='.$row['pd_id'].'">Remove</a></li>';?></td>
#4
Re: Delete from database upon action selected
Posted 02 August 2012 - 09:31 AM
Since I have to guess at your database layout, I would assume that $row['pd_id'] your defining id for the row, so :
delete from table_name where id='$row[pd_id]';
If that isn't correct, we need to see how your database is setup.
delete from table_name where id='$row[pd_id]';
If that isn't correct, we need to see how your database is setup.
Quote
Though I would recommend you learn from the provided statement, & do it safely & correctly.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|