MySQL DELETE

For some reason this isn’t deleteing it from the database D=

Here is my code:

[code]<?php
require_once ‘header.php’;
require_once ‘connect.php’;
//This code runs if the form has been submitted
if (isset($_POST[‘submit’])) {
while($row = mysql_fetch_array($result))
{

// now we insert it into the database
$insert = (“DELETE FROM ‘items’ WHERE ‘id’ = '”.$_GET[‘id’]."’");
$add_member = mysql_query($insert);
}
?>

Item Deleted

<< Back to item admin.

<?php } else { $result = mysql_query("SELECT * FROM `items` WHERE `id` = '".$_GET['id']."'"); while($row = mysql_fetch_array($result)) { ?>
Item Name: <?php echo $row['itemName'];?>
Item Description: <?php echo $row['itemDesc'];?>
Picture URL: <?php echo $row['itemPic'];?>
Price: <?php echo $row['itemPrice'];?>

Note: We have not given options to edit price and button codes to stop confusion.

<?php } } ?> [/code]

Any help would be greatly appreciated.

-Jordan

Where is the $result variable for the first WHILE loop? You are giving WHILE something that you don’t have and therefor the condition will always turn false and not run. It looks like you really don’t need the first while loop. Get rid of the first while loop and just have the MySQL code and it should work.

Sponsor our Newsletter | Privacy Policy | Terms of Service