The delete script finds the records entered and displays them in a combo box perfectly fine, then when I press the button to tell it to delete it says that it has deleted the record, but when looking at the tables in the database, the values are still in them.
Delete Script
Code: Select all
if ($_POST['op'] != "delete") {
//haven't seen the form, so show it
$display_block = "<h1>Select a Book</h1>";
//get parts of records
$get_list = "select id, concat_ws(', ', item_name) as display_name from store_items";
$get_list_res = mysql_query($get_list) or die(mysql_error());
if (mysql_num_rows($get_list_res) < 1) {
//no records
$display_block .= "<p><em>Sorry, no records to select!</em></p>";
} else {
//has records, so get results and print in a form
$display_block .= "
<form method=\"post\" action=\"$_SERVER[PHP_SELF]\">
<p><strong>Select a Record to Delete:</strong></p><br>
<select name=\"sel_id\">
<option value=\"\">-- Select One --</option>";
while ($recs = mysql_fetch_array($get_list_res)) {
$id = $recs['id'];
$display_name = stripslashes($recs['display_name']);
$display_block .= "<option value=\"$id\">
$display_name</option>";
}
$display_block .= "
</select>
<input type=\"hidden\" name=\"op\" value=\"delete\">
<p><input type=\"submit\" name=\"submit\" value=\"Delete Selected Entry\"></p>
</form>";
}
} else if ($_POST['op'] == "delete") {
//check for required fields
if ($_POST['sel_id'] == "") {
header("Location: delbook.php");
exit;
}
//issue queries
$del_items = 'DELETE FROM store_items WHERE id = '.$_POST['sel_id'];
mysql_query($del_items) or die(mysql_error());
$del_books = 'DELETE FROM store_books WHERE id = '.$id;
mysql_query($del_books) or die(mysql_error());
$display_block = "<h1>Record(s) Deleted</h1>
<p>Would you like to
<a href=\"$_SERVER[PHP_SELF]\">delete another</a></p>";
}As for the add image script I've been using the following guide on this site:
http://www.evolt.org/article/Storage_an ... /20/27237/
The only thing I changed in the upload.php script was:
The database table containg the image info to store_images
The database connection and database name
And the img.php file is the same as the one from the site, no changed were made for this.