Jump to content

data does't deleted ?


tshing70
 Share

Recommended Posts

I want to delete the data when i click the delete text, but it does't work, any idea???This is my listing,php<CENTER><?php$con = mysql_connect ("localhost","root","");if (!$con){die('Could not connect: ' .mysql_error());}mysql_select_db("member_db", $con); $result = mysql_query("SELECT * FROM newmember"); echo "<table border='1'><tr><th>Id</th><th>Name</th><th>Gender</th><th>DOB</th><th>Address</th><th>State</th><th>Is Member</th></tr>"; while($row = mysql_fetch_array($result)){echo "<tr>";echo "<td>" . $row['P_Id'] ."</td>";echo "<td>" . $row['Name'] ."</td>";echo "<td>" . $row['Gender'] ."</td>";echo "<td>" . $row['Dob'] ."</td>";echo "<td>" . $row['Address'] . "</td>";echo "<td>" . $row['State'] . "</td>";echo "<td>" . $row['Ismember'] . "</td>";echo ("<td><a href=\"editinfo.php?id=$row[P_Id]\">Edit</a></td>");echo ("<td><a href=\"delete.php?id=$row[P_Id]\">Delete</a></td></tr>");}echo "</table>"; mysql_close($con);?></CENTER> My delete.php <?php $con = mysql_connect ("localhost","root","");if (!$con){die('Could not connect: ' .mysql_error());}mysql_select_db("member_db", $con); $order = "DELETE FROM newmember WHERE P_id='$id'"; mysql_query($order); header("location:listing.php");?>

untitled.bmp

Link to comment
Share on other sites

For the delete.php, looks like you're not using $_GET to retrieve the id. For ie: $id = $_GET['id']; To also note, since the id is a number, you don't need to use single quotes for it in the query:$order = "DELETE FROM newmember WHERE P_id=$id";

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...