Delete one data from database table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rickngjh
Forum Newbie
Posts: 1
Joined: Wed Jan 19, 2011 9:38 pm

Delete one data from database table

Post by rickngjh »

Code: Select all

shoppingcart.php: 
<a href="delete.php">Delete</a>

delete.php:
<?php 

session_start();

$conn = mysql_connect("localhost" , "root" , "");
    mysql_select_db("dbouterspace" , $conn);
 

$id_row= "1" ;
$query = "DELETE * FROM confirm_order WHERE ItemID = "$_GET['$id_row']""; 
$result = mysql_query($query); 

echo "The data has been deleted.";

header("Location:shoppingcart.php"); 
?> 


User avatar
iijb
Forum Commoner
Posts: 43
Joined: Wed Nov 26, 2008 11:34 pm

Re: Delete one data from database table

Post by iijb »

Hi,
Please specify your problem.
I think you are using Get method to get ItemId for the deletion. But you are not passing the ItemId in the url in the delete link of shoppingcart.php

Regards
iijb
thecodewall
Forum Commoner
Posts: 33
Joined: Sun Dec 26, 2010 8:37 am

Re: Delete one data from database table

Post by thecodewall »

maybe this help...

Code: Select all

$query = "DELETE * FROM confirm_order WHERE ItemID = '".$_GET['$id_row']."'"; 
http://codewall.blogspot.com
Post Reply