tshing70 Posted July 9, 2012 Report Share Posted July 9, 2012 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 More sharing options...
Don E Posted July 9, 2012 Report Share Posted July 9, 2012 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"; 1 Link to comment Share on other sites More sharing options...
tshing70 Posted July 9, 2012 Author Report Share Posted July 9, 2012 It work, thank you so much Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now