SQL statements in my PHP Page??
Posted: Wed May 23, 2007 10:25 am
This bit of code below is to delete an answer from my forum, then once deleted to go to the question table in mysql and - 1 off the reply column for the question the answer has just been deleted off, the answer is being deleted but the reply column is not dropping down one, wondering if any one can help me, the code for it is shown below.
This is the part that i believe to be the problem not sure whether ive written it right
Any help would be greatly appreciated
Many Thanks In Adavance
Chris
Code: Select all
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Get values from form.
$id=$_GET['a_id'];
// Do delete statement.
mysql_query("delete from forum_answer where a_id='$id'");
$tbl_name2="forum_question"; // Switch to table "forum_question"
// Get values from form.
$id=$_GET['id'];
// Do delete statement.
mysql_query("UPDATE forum_question SET reply = reply - 1 WHERE id = $id");
// Close database connection
mysql_close();
// Redirect to select.php.
header("location:main_forum.php");Code: Select all
$tbl_name2="forum_question"; // Switch to table "forum_question"
// Get values from form.
$id=$_GET['id'];
// Do delete statement.
mysql_query("UPDATE forum_question SET reply = reply - 1 WHERE id = $id");Many Thanks In Adavance
Chris