wiggst3r Posted July 8, 2008 Share Posted July 8, 2008 Hi I have a for loop that outputs info from my database. I want next to each to have a link with a delete button, when clicked, the row gets deleted, based on the 'catid' My code is as follows: foreach($list as $item) { if(isset($_GET['state']) && $_GET['state'] == 'edit' && $_GET['id'] == $item['catid']) { ///display row with values inside form fields } else { //display normal row ?> <div id="item_<?=$item['catid'];?>"> <p class="briefed"><?=$item['briefed'];?></p> <p class="job_number"><?=$item['job'];?></p> <p class="category"><?=$item['category'];?></p> <p class="needed"><?=$item['needed'];?></p> <p class="status"><?=$item['status'];?></p> <p class="order_id"><?=$item['orderid'];?></p> <p class="link"><a href="index.php?state=edit&catid=<?=$item['catid']?>">Edit</a></p> <p class="delete"><a href="delete_row.php"></a><img src="images/cross.png" border="0" /></a></p> </div> <? } } ?> Anyone know what I need to add tot the delete section and what needs to be in delet_row.php? Thanks Link to comment https://forums.phpfreaks.com/topic/113739-delete-row-in-mysql/ Share on other sites More sharing options...
lemmin Posted July 8, 2008 Share Posted July 8, 2008 You need some id that can be used to reference the row you want to delete: <p class="delete"><a href="delete_row.php?p=<?php item['primarykey'] ?>"></a><img src="images/cross.png" border="0" /></a></p> Then, in delete_row.php: "DELETE FROM Table WHERE PrimaryKey = ".$_GET['primarykey']; Link to comment https://forums.phpfreaks.com/topic/113739-delete-row-in-mysql/#findComment-584528 Share on other sites More sharing options...
wiggst3r Posted July 8, 2008 Author Share Posted July 8, 2008 I used this: <p class="delete"><a href="delete_row.php?catid=<?=$item['catid']?>">delete</a></p> Worked perfectly Link to comment https://forums.phpfreaks.com/topic/113739-delete-row-in-mysql/#findComment-584545 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.