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
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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.