Jump to content
Sign in to follow this  
p8baller07

Halp! PHP issues

Recommended Posts

Okay so i'm trying to return all the values for "data" within the rows of a table with a delete button next to them.

 

 

 

It all works so far, except the delete button doesnt delete

 

 

 

mysql_select_db("alinco_alincosite", $con);

  $result = mysql_query("select * from news order by id desc");

  $id = $_GET['ID'];

  if (isset($id))

  {

  mysql_query("DELETE FROM news WHERE ID = '$id'");

  echo "Post deleted!";

  }

  while($r=mysql_fetch_array($result))

  {

  echo $r["data"];

  echo "<a href=\"?del=".$r['ID']."\">Delete</a><br />";

  }

Share this post


Link to post
Share on other sites

You are telling it to get the value of ID from the query string, but that value isn't there.

 

$id = $_GET['ID'];

echo "<a href=\"?del=".$r['ID']."\">Delete</a><br />";

 

You should be able to either change the value in the $_GET or the query string value apended to the url.

Share this post


Link to post
Share on other sites
You are telling it to get the value of ID from the query string, but that value isn't there.

 

$id = $_GET['ID'];

echo "<a href=\"?del=".$r['ID']."\">Delete</a><br />";

 

You should be able to either change the value in the $_GET or the query string value apended to the url.

 

Is there a way to put the ID value in that query string?

Share this post


Link to post
Share on other sites
This should work... I'm got a migraine and cannot see clearly ATM...

 

echo "<a href=\"?id=".$r['ID']."\">Delete</a><br />";

That worked i just had to chang ?id= to ?ID= :)

 

Thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×