Hi guys i have this problem. I have a while loop that shows me the values of a table. Now I need you may delete one of them, if it is wrong. I just can not run this code , I do not understand what is wrong. This is my php where i have the problem.
while( $row = mysql_fetch_array( $res ))
{
echo "<tr>
<td> ".$row['id']."</td>
<td> ".$row['val1']."</td>
<form action='' method='POST'>
<input type='submit' name='delete' value='".$row['id']."' /></td>
</form>
</tr>";
}
if(isset($_POST['delete'])){
$user = $_POST['delete'];
$delet_query = mysql_query("DELETE FROM table_name WHERE id = '$user' ") or die(mysql_error());
if($delet_query) {
echo "Delete success!";
}
}
Why don't work? Thanks a lot man! I need the user can delete the row.