Jump to content

Adding a delete button to each record


zamanbux

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/262846-adding-a-delete-button-to-each-record/
Share on other sites

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?

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...  ;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.