Using the following code:
if (isset($_POST['delete']) && isset($_POST['id']))
{
$first = get_post('first');
$query = "DELETE FROM user_master WHERE id='$id'";
if(!mysql_query($query, $db_server))
echo "DELETE failed: $query<br />" .
mysql_error() . "<br /><br />";
}
$query="SELECT * FROM user_master";
$result= mysql_query($query);
if(!result) die ("Database access failed: " . mysql_error());
$rows = mysql_num_rows($result);
for ($j=0 ; $j<$rows ; ++$j)
{
$row = mysql_fetch_row($result);
echo <<<_END
<pre>
ID $row[0]
First $row[1]
Last $row[2]
Email $row[3]
User $row[4]
</pre>
<form action="willingLog.html" method="post">
<input type="hidden" name="delete" value="yes" />
<input type="hidden" name="id" value="$row[0]" />
<input type="submit" value="DELETE RECORD" /></form>
_END;
I'm unable to delete a record form the table.
All the records form the table are printing on the screen, including the "DELETE RECORD" button. When I hit the button, however, nothing happens. I've checked the actual table on phpmyadmin, and the table is unaffected as well.
I'm pulling this stuff from a book, so I don't understand why it's not working.
$_POST?DELETE FROM? Where are they?$first = get_post('first');? Is it setting a variable? Add some debugging and echo out your SQL statement to make sure it looks like what you think it looks like.