Jump to content

Delete things...


dean7

Recommended Posts

Hi all,

On my website ive got a forum, which im trying to code somthing for it so you can delete the topic but im not sure how to do this.. Ive tryed many ways but its deleted all the topics not just the one.

 

This is part of my forum code where im trying to make the button so they can delete it:

<td align="center" bgcolor="#FFFFFF"><?php echo $rows['datetime']; ?></td>
<td align="center" bgcolor="#FFFFFF">***<a href="delete.php?delete=delete&id=$id">Delete</a>***
</td>
</tr>

 

And this is my delete.php file:

<?php
session_start();
include ("main_forum.php");
include ("includes/config.php");

if ($_GET['delete']){
$sql = "DELETE FROM forum_question WHERE id=$id";
$result = mysql_query($sql);
echo "Topic Deleted!";
?>

 

Anyone know a way that i can delete topics without delete every one of them?

 

Thanks for your help:)

Link to comment
Share on other sites

Hi Buddy,

 

You don't seem to be passing the id through to the delete file, if ($_GET['delete']){ this checks if you want to delete the file, but then we need the id to tell mysql to delete.

 

if you put: $id = $_GET['id'];

 

in the delete file to that should work :)

 

Graham

 

 

Link to comment
Share on other sites

Hi Mate,

 

That will always say "Topic Deleted" because it's next in line to execute to find out if it's really deleted do:

 

<?php
if ($sql) // Thgis checks if the delete was successful (true) else (false)
{
print "Topic Deleted";
} else {
print "An error occured deleting the topic!";
}
?>

 

When you hover your cursor over: <a href="delete.php?delete=delete&id=$id">Delete</a>*** do you see the ID in the bottom left window in explorer?

 

Graham

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.