zamanbux Posted May 20, 2012 Share Posted May 20, 2012 Hi I've been scouring the net and I cant find anything that works. Can someone tell me how to put a delete button next to each record? Any help is appreciated, thank you! $term = strtolower ($_POST['term']); $sql = mysql_query("select * from $table where first like '%$term%' or last like '%$term%'"); while ($row = mysql_fetch_array($sql)){ echo 'ID: '.$row['id']; echo '<br/> first: '.$row['first']; echo '<br/> last: '.$row['last']; echo '<br/> phone: '.$row['phone']; echo '<br/> mobile: '.$row['mobile']; echo '<br/> fax: '.$row['fax']; echo '<br/> email: '.$row['email']; echo '<br/> web: '.$row['web']; echo '<br/><br/>'; } ?> </p> Quote Link to comment https://forums.phpfreaks.com/topic/262846-adding-a-delete-button-to-each-record/ Share on other sites More sharing options...
chris-s Posted May 20, 2012 Share Posted May 20, 2012 Not entirely sure what you're asking but... echo '<br/> phone: '.$row['phone'] . ' <a href="somehere.php">Delete</a>'; ? Quote Link to comment https://forums.phpfreaks.com/topic/262846-adding-a-delete-button-to-each-record/#findComment-1347168 Share on other sites More sharing options...
zamanbux Posted May 21, 2012 Author Share Posted May 21, 2012 Not entirely sure what you're asking but... echo '<br/> phone: '.$row['phone'] . ' <a href="somehere.php">Delete</a>'; ? Thank you. It is exactly what I'm looking for. I am very new to PHP but another question, where "somehere.php" goes, what should be there? I've found something about a "delete.php" but how does it work and what's the code for it? Or in general, how do you actually get it to delete the record? Quote Link to comment https://forums.phpfreaks.com/topic/262846-adding-a-delete-button-to-each-record/#findComment-1347170 Share on other sites More sharing options...
zamanbux Posted May 21, 2012 Author Share Posted May 21, 2012 Bump Quote Link to comment https://forums.phpfreaks.com/topic/262846-adding-a-delete-button-to-each-record/#findComment-1347414 Share on other sites More sharing options...
TOA Posted May 22, 2012 Share Posted May 22, 2012 You'd change it to whatever page handles the deleting. This could even be the same script if you set it up that way. Construct the link with some kind of identifying id. On the page you handle deletes on, you'd grab the id your passing over using $_GET, escape it and run the query to delete the record with that id. I assume you have a unique key in that 'Select *' there... Quote Link to comment https://forums.phpfreaks.com/topic/262846-adding-a-delete-button-to-each-record/#findComment-1347460 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.