Jump to content

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

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.