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

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.   Paste as plain text instead

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...