waVes Posted March 10, 2007 Share Posted March 10, 2007 Hi, I am new to PHP and MySQL but I have setup a MySQL database. I can view the information in an HTML table using PHP scripts and can delete an entry form the database table, but what i need to do is to be able to delete an entry by selecting a radio button next to the relevent information however when i try to add a form in the PHP script i get an error. Thanks in advance for any help. Link to comment https://forums.phpfreaks.com/topic/42160-delete-data-from-mysql-database/ Share on other sites More sharing options...
per1os Posted March 10, 2007 Share Posted March 10, 2007 Code would be nice. --FrosT Link to comment https://forums.phpfreaks.com/topic/42160-delete-data-from-mysql-database/#findComment-204550 Share on other sites More sharing options...
waVes Posted March 11, 2007 Author Share Posted March 11, 2007 Hi, This is what I have at the moment which works but can't just select a line to delete it <html> <head> <title>Racing World</title> </head> <body> this is Track management <form action="trackaddprocess.php" method="post"> Add Track: <input type="text" name="track"><br> <input type="submit" value="Submit"> </form> <form action="trackdelprocess.php" method="post"> delete Track: <input type="text" name="track"><br> <input type="submit" value="Submit"> </form> <?php mysql_connect("localhost", "root", "qwe") or die(mysql_error()); mysql_select_db("race") or die(mysql_error()); $data = mysql_query("SELECT * FROM track") or die(mysql_error()); Print "<table border cellpadding=3>"; Print "<tr><th>TrackID</th><th>TrackName</th></tr>"; while($info = mysql_fetch_array( $data )) { Print "<tr><td>".$info['TrackID'] . "</td><td>".$info['TrackName'] . "</td></tr>"; } Print "</table>"; ?> </body> </html> I need something along the lines of the following to enable me to just select a line and then delete that information from the database <form action="trackdelprocess.php" method="post"> <table border cellpadding=3> <tr><th>h1</th><th>h2</th><th>Radio</th></tr> <tr><td>c1r1</td><td>c2r1</td><td><input type="radio" name="group1" value="a variable"></td></Tr> <tr><td>c1r2</td><td>c2r2</td><td><input type="radio" name="group1" value="a variable"></td></Tr> <tr><td>c1r3</td><td>c2r3</td><td><input type="radio" name="group1" value="a variable"></td></Tr> </table> <input type="submit" value="delete"> </form> Cheers waves Link to comment https://forums.phpfreaks.com/topic/42160-delete-data-from-mysql-database/#findComment-204691 Share on other sites More sharing options...
sanjayshiwakoti Posted March 11, 2007 Share Posted March 11, 2007 <? if($_GET['m']=="D"){ $sql="delete from track where id=".$_GET['id']; mysql_query($sql); } ?><html> <head> <title>Racing World</title> </head> <body> this is Track management <form action="trackaddprocess.php" method="post"> Add Track: <input type="text" name="track"> <input type="submit" value="Submit"> </form> <form action="trackdelprocess.php" method="post"> delete Track: <input type="text" name="track"> <input type="submit" value="Submit"> </form> <?php mysql_connect("localhost", "root", "qwe") or die(mysql_error()); mysql_select_db("race") or die(mysql_error()); $data = mysql_query("SELECT * FROM track") or die(mysql_error()); Print "<table border cellpadding=3>"; Print "<tr><th>TrackID</th><th>TrackName</th></tr>"; while($info = mysql_fetch_array( $data )) { Print "<tr><td>".$info['TrackID'] . "</td><td>".$info['TrackName'] . "</td><td><a href='page_name.php?m=D&id=$info['TrackID']'>delete</a></td></tr>"; } Print "</table>"; ?> </body> </html> I need something along the lines of the following to enable me to just select a line and then delete that information from the database <form action="trackdelprocess.php" method="post"> <table border cellpadding=3> <tr><th>h1</th><th>h2</th><th>Radio</th></tr> <tr><td>c1r1</td><td>c2r1</td><td><input type="radio" name="group1" value="a variable"></td></Tr> <tr><td>c1r2</td><td>c2r2</td><td><input type="radio" name="group1" value="a variable"></td></Tr> <tr><td>c1r3</td><td>c2r3</td><td><input type="radio" name="group1" value="a variable"></td></Tr> </table> <input type="submit" value="delete"> </form> Link to comment https://forums.phpfreaks.com/topic/42160-delete-data-from-mysql-database/#findComment-204717 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.