i delete a row of data from this

........
<a href="delete.php?id=<? echo $rows['id']; ?>">delete</a>

delete.php

<html>
<body>
<?php
include 'recipe2db.php';

// get value of id that sent from address bar
$id=$_POST['id'];

// Delete data in mysql from row that has this id
$sql="delete from recipe where `id` = '".$id."'";
$result=mysql_query($sql);

// if successfully deleted
if($result){
echo "Deleted Successfully";
echo "<BR>";
echo "<a href='home.php'>Back to main page</a>";
}

else {
echo "ERROR (".mysql_errno()."):";
echo mysql_error();
}

// close connection
mysql_close();

?>
</body>
</html>

but, it doesn't delete well.. from the display or from the database.
is it my code ok? or have any error.. help me..

Recommended Answers

All 2 Replies

Have you established a valid connection to the database?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.