Jump to content


Photo

Database Queries


  • Please log in to reply
4 replies to this topic

#1 robcrozier

robcrozier
  • Members
  • PipPipPip
  • Advanced Member
  • 175 posts

Posted 12 March 2006 - 06:08 PM

hi can anyone help me?

what im trying to do is output some data from a mysql table into a table on the bowser. However the tricky part is that i want each row that is outputted to have a link beside it which when clicked will delete that row from the table.

Ive got the basic table outputting at the min and just need to add the delete link.

Oh and the table is being outputted in a loop.

Help would be massively appreciate!!!!!

#2 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 12 March 2006 - 06:15 PM

if each item in your table has an id number... something similar to that below would work.

<a href="delete_entry.php?id=<?=$id?>">Delete This Entry</a>

<?php 
$id = $_GET['id'];
$query = mysql_query(DELETE * FROM your_table WHERE id_field = $id);
?>

Might not be exactly right, but it will nudge you along the right path.
wisewood: proven fact, I am both wise, and wooden.

#3 robcrozier

robcrozier
  • Members
  • PipPipPip
  • Advanced Member
  • 175 posts

Posted 12 March 2006 - 06:29 PM

Cheers mate that looks like what im after but lets just get this straight. The first bit of code is to go into the print statements when outputting the table and the second section foms the delete_entry.php page?

Thanx a lot mate!

#4 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 12 March 2006 - 06:39 PM

Correct.
Legend has it that reading the manual never killed anyone.
My site

#5 robcrozier

robcrozier
  • Members
  • PipPipPip
  • Advanced Member
  • 175 posts

Posted 13 March 2006 - 03:13 PM

It doesnt seem like the variable $id is being passed to the delete_entry page for some reason! im trying to simply echo the variable on the new page and nothing is being displayed.

Can anyone help???




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users