Jump to content

Stupid Delete Query


beansandsausages

Recommended Posts

Hey all, i am trying to delete a row. Here is my code :

 

if($_GET['action'] == "delete")
	{
	$id = $_POST['delete_id'];

   $sql =	"DELETE FROM `news` WHERE id='{$id}' ";
echo " <br /> <div class=\"textboxright\"> <h2><u>Delete Game Message ID : {$id}</u></h2> <p>Message Deleted ID : {$id} <br /> <a href=mem.php>back</a></p> </div>"; } 

 

the code {$id} echos the number 1 witch is correct its just not geting deleted from the db im well confused.

Link to comment
https://forums.phpfreaks.com/topic/92429-stupid-delete-query/
Share on other sites

This is the full code As messy as it is

 

<?php 

if($_GET['action'] == "delete")
				{
					$id = $_POST['delete_id'];

				if($info[security] <= 7 ) { echo " no"; } 
				else 
				{ 

				$sql ="DELETE FROM `news` WHERE `id`='{$id}'";
				echo " <br /> <div class=\"textboxright\"> <h2><u>Delete Game Message ID : {$id}</u></h2> <p>Message Deleted ID : {$id} <br />  <a href=mem.php>back</a></p> </div>"; } 

				}



		// start of the game script MUST HAVE <h2> tag




		// game messages box 
if($game_show == "Y" )
	{
	echo " <div class=\"textboxright\"> <h2><u>Game Messages</u></h2> ";

		$sql = "SELECT * FROM `news` ORDER BY id LIMIT 0,5";
		$result = mysql_query($sql);
		if (!$result) {
    			echo "Could not successfully run query ($sql) from DB: " . mysql_error();
    			exit;
		}

		if (mysql_num_rows($result) == 0) {
    			echo "<p>No news posted. </div></p>";
    			include_once("layout_all/bottom.php");
		exit;
		}

		while ($row = mysql_fetch_assoc($result)) {
    				
		echo "<p> {$row["date"]} : {$row["time"]} : Poster {$row["poster"]}                             {$row["message"]} </p> <br /> "; 
				if($info[security] >= 8 ) { echo "<p><form action=\"?action=delete\" method=\"POST\"><input type=\"hidden\" name=\"delete_id\" id=\"delete_id\" value=\"{$row['id']}\"><input type=\"submit\" value=\"Delete Post : {$row["id"]}\" > </form> <form action=\"mem.php?action=edit\" method=\"POST\"><input type=\"hidden\" name=\"edit_id\" id=\"edit_id\" value=\"{$row['id']}\"><input type=\"submit\" value=\"Edit Post : {$row["id"]}\" ></form></p> <br />"; } 


			}

			mysql_free_result($result);


			echo " 	</div>  <div class=\"clear\">";
			}


		if($_GET['action'] == "showoff" ) { $update_gameshow = mysql_query("UPDATE `members` SET game_show='N' WHERE id='$info[id]'"); echo " Done "; }	
		elseif($_GET['action'] == "showon" ) { $update_gameshow = mysql_query("UPDATE `members` SET game_show='Y' WHERE id='$info[id]'"); echo " Done"; }	






All works apart from this code

if($_GET['action'] == "delete")
				{
					$id = $_POST['delete_id'];

				if($info[security] <= 7 ) { echo " no"; } 
				else 
				{ 

				$sql ="DELETE FROM `news` WHERE `id`='{$id}'";
				echo " <br /> <div class=\"textboxright\"> <h2><u>Delete Game Message ID : {$id}</u></h2> <p>Message Deleted ID : {$id} <br />  <a href=mem.php>back</a></p> </div>"; } 

				}

but if echoed out {$id} are a id number so i dont know.

 

Link to comment
https://forums.phpfreaks.com/topic/92429-stupid-delete-query/#findComment-473648
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.