felipeebs Posted March 29, 2007 Share Posted March 29, 2007 Hi! I'm trying to make a function, or something like that, to delete a row from a mysql table The script that show the stuff runs OK now... I don't know how to make a link and the function to delete here is my FULL script: <?php header("Content-Type: text/html; charset=ISO-8859-1",true) ?> <?php $admin = $_GET['admin']; $conexao = mysql_connect("localhost","root","schmitz"); mysql_select_db("felipeebs"); if(isset($admin) && $admin == "password") { // Counter script BEGIN $quant = mysql_query("SELECT * FROM newsletter"); $conta = mysql_num_rows($quant); echo "<p>Registered e-mails: " . $conta . "</p>"; // Counter script END $sql = "SELECT * FROM newsletter order by nome"; $query = mysql_query($sql); echo "<table>"; while($lista = mysql_fetch_array($query)) { echo "<tr><td style=\"width:150px; border:solid 1px #000;\">" . $lista["nome"] . "</td><td style=\"width:300px; border:solid 1px #000;\">" . $lista["email"] . "</td><td><a href=\"verif.php?admin=" . $admin . "&del=" . $lista["email"] . "\">Remove</a></td></tr>"; } echo "</table>"; } else { echo "Only admins allowed..."; } ?> inside the while I've inserted the stuff i want (if possible): &del=" . $lista["email"] . " in the "remove" link If anyone can help Link to comment https://forums.phpfreaks.com/topic/44842-solved-help-with-a-function-or-something-to-delete-sql-stuff/ Share on other sites More sharing options...
shaunrigby Posted March 29, 2007 Share Posted March 29, 2007 try passing an action aswell, eg: echo "<tr><td style=\"width:150px; border:solid 1px #000;\">" . $lista["nome"] . "</td><td style=\"width:300px; border:solid 1px #000;\">" . $lista["email"] . "</td><td><a href=\"verif.php?act=del&admin=" . $admin . "&del=" . $lista["email"] . "\">Remove</a></td></tr>"; Then, in verif.php as either an if statement or a switch to determine the action Link to comment https://forums.phpfreaks.com/topic/44842-solved-help-with-a-function-or-something-to-delete-sql-stuff/#findComment-217780 Share on other sites More sharing options...
felipeebs Posted March 29, 2007 Author Share Posted March 29, 2007 Let me try... The if: if(isset($del) && $act == "del") { $sql = "DELETE FROM `newsletter` WHERE CONVERT(`newsletter`.`email` USING utf8) = '$del'"; $query = mysql_query($sql); echo "deled"; } Thelink stuff: echo "<tr><td style=\"width:150px; border:solid 1px #000;\">" . $lista["nome"] . "</td><td style=\"width:300px; border:solid 1px #000;\">" . $lista["email"] . "</td><td><a href=\"verif.php?admin=" . $admin . "&act=del&del=" . $lista["email"] . "\">Remover</a></td></tr>"; and the result: THANK YOU Link to comment https://forums.phpfreaks.com/topic/44842-solved-help-with-a-function-or-something-to-delete-sql-stuff/#findComment-217795 Share on other sites More sharing options...
shaunrigby Posted March 29, 2007 Share Posted March 29, 2007 No problem, now please mark your thread as resolved in the bottom left of the page Link to comment https://forums.phpfreaks.com/topic/44842-solved-help-with-a-function-or-something-to-delete-sql-stuff/#findComment-217803 Share on other sites More sharing options...
felipeebs Posted March 29, 2007 Author Share Posted March 29, 2007 Topic Solved Link to comment https://forums.phpfreaks.com/topic/44842-solved-help-with-a-function-or-something-to-delete-sql-stuff/#findComment-217804 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.