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
https://forums.phpfreaks.com/topic/184070-delete-things/
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
https://forums.phpfreaks.com/topic/184070-delete-things/#findComment-971780
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
https://forums.phpfreaks.com/topic/184070-delete-things/#findComment-971784
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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