I'm trying to delete a row in a table in my database, but it isn't working... The connection works. I've echoed the table row id to ensure it is working and still it won't delete...
Let me know if you need the connection code too.
code:
<table>
<tr>
<td>Recent Posts</td>
</tr>
<?php while($row = mysql_fetch_array($result)) : ?>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['phone number']; ?></td>
<td><a href="delete2.php?id=<?php echo $row['id'];?>">Schedule</a></td>
</tr>
<?php endwhile; ?>
</table>
delete.php code:
<?php
$b=$_GET['id'];
$sql='DELETE FROM on call WHERE id=$b';
//echoing just to make sure it is working correctly...
echo $b;
?>
</br>
</br>
<a href='index2.php'>back to list</a>
mysql_queryshould not be used in new applications. It's a deprecated interface that's being removed from future versions of PHP. A modern replacement like PDO is not hard to learn. A guide like PHP The Right Way will help you avoid making mistakes like this.on call, you'll need to wrap it in backticks. (And I'd suggest renaming it so it doesn't have a space in the name).