Posted: Sat Feb 09, 2008 10:59 pm Post subject: Problems with Delete Row Function
<?php /* Created on: 2/9/2008 */
//the code starts here
// we then will connect to the database as the user specified
mysql_connect("$nil","$nil","$nil")
// now if we cannot connect to the database then this message will be displayed followed by the error message
or die ('I cannot connect to the database because: ' . mysql_error());
// here we are choosing which database we really want to edit. For us this database happens to be "sqlslave"
mysql_select_db("sqlslave")
// if it doesn't select the database the connection will die
or die(mysql_error());
//If cmd has not been initialized
if(!isset($cmd))
{
// get all committee names from the database
$result = MYSQL_QUERY("select * from COMMITTEE order by Committee");
while ($row = mysql_fetch_array($result))
{
// grabbing the title of the committee names
$title = $row['Committee'];
$committee = $row['Committee'];
//make the title a link
echo "<a href='delete.php?cmd=delete&$tablename=$committee'>$title - Delete</a>";
echo "<br>";
}
}
?>
<?
if($_GET['cmd']=="delete")
{
$dbh=mysql_connect ("$nil", "$nil", "$nil")
or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("sqlslave");
// delete table
$sql = "DELETE FROM COMMITTEE WHERE Committee=$committee LIMIT 1";
mysql_query($sql,$dbh);
echo "The committee has been deleted.";
}
?>
-------------------------------------------------------------------------------------
Okay so my problem here is that everything is showing properly up to the display but when I click one of the links meant to delete the row from the table it refuses to delete the row, yet the end echo still shows that it was deleted. Upon hitting the back button in my browser and logging into the DB the row that was supposed to be deleted is still there.
Someone please help!!! =)
thanks a bunch,
P.S- Please note that $nil is just a variable that was used to edit out my host/user/pw
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum