ambo Posted January 8, 2009 Share Posted January 8, 2009 Hey I have a basic comment script and i want to be able to make a link that says delete next to a message DELETE FROM `comments` WHERE CONVERT(`comments`.`author` USING utf8) = 'admin' AND CONVERT(`comments`.`user` USING utf8) = 'Glenh' AND CONVERT(`comments`.`comment` USING utf8) = 'Enter your comment here....' AND CONVERT(`comments`.`date` USING utf8) = '01/8/09 05:58 pm' LIMIT 1; <? include("admin/dbconnect.php"); $getcomments = mysql_query("select * FROM comments WHERE user = '$req_user' ORDER BY date DESC"); while($r=mysql_fetch_array($getcomments)){ extract($r); echo "<tr><td colspan=\"2\"><span class=\"style13\">From $author $date</span></td></tr>"; echo "<tr><td colspan=\"2\"><hr width=\"95%\" color=\"#000000\" /></td></tr>"; echo "<tr><td width=\"10\"> </td><td width=\"380\"><div align=\"left\"><span class=\"Style12\">$comment</span></div></td></tr>"; echo "<tr><td>-</td><td align=\"left\"><a href=\"profile.php?user=$author\">Reply</a>DELETE COMMENT</td></tr>"; } ?> Link to comment https://forums.phpfreaks.com/topic/140083-delete-row-from-comment/ Share on other sites More sharing options...
timmah1 Posted January 8, 2009 Share Posted January 8, 2009 Why don't you pass the comment ID to the delete link, then delete the entire row from the database? <?php echo "<a href='delete.php?id=$id'>DELETE COMMENT</a>"; ?> Then delete it <?php $sql = "DELETE FROM comments WHERE id = '".$_GET['id']."'"; ?> Link to comment https://forums.phpfreaks.com/topic/140083-delete-row-from-comment/#findComment-732929 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.