Jump to content

Deleting a row in mysql...it doesnt work.


strujillo

Recommended Posts

ok so i have an internal email system, where any one who is a member can send each other a message. Well i got it to display the messages and everything but i cant get it to delete the message. here is the code.

 

email_inbox.php

<?php
$title="Email: Inbox";
include("body.php");

include("dbconnect.php");
$username=$_SESSION["myusername"];
//This selects the message where it has not been read alread, thats why it only pick
//the messages with stats to 0
$sql ="SELECT * FROM `abhs`.`messages` WHERE `to`='$username' AND `stats`='0'"; 

$result=mysql_query($sql);

echo"<center>";
echo"<table width=\"515\" border=\"1\" cellpadding=\"5\" bgcolor=\"#00ffff\">";
  echo"<tr>";
  	echo"<td width=\"65\">Status</td>";
    echo"<td width=\"100\">To </td>";
    echo"<td width=\"100\">From </td>";
    echo"<td width=\"150\">Subject </td>";
echo"<td width=\"100\">Options</td>";
  echo"</tr>";
echo"</table>";
echo"</center>";


while($row = mysql_fetch_array($result)){

$to = $row[to];
$from=$row[from];
$subject=$row[subject];
$message=$row[message];
$id=$row[id];

echo"<center>";
echo"<table width=\"515\" border=\"1\" cellpadding=\"5\" bgcolor=\"#ececec\">";
  echo"<tr>";
	echo"<td width=\"65\">Unread</td>";
	echo"<td width=\"100\">$to </td>";
	echo"<td width=\"100\">$from </td>";
	echo"<td width=\"150\">$subject </td>";
	echo"<td width=\"100\"><form method=\"get\" name=\"options\"><input type=\"submit\" name=\"view\"value=\"View\"></form>";
  echo"</tr>";
echo"</table>";

if(isset($_GET["view"])==1){

				echo"<table width=\"500\" border=\"1\" cellpadding=\"5\">";
		echo"<tr>";
			echo"<td bgcolor=\"#00FFFF\" width=\"100\">To:   </td>";
			echo"<td bgcolor=\"#CCFFFF\"> $to </td>";
		  echo "</tr>";
		  echo "<tr>";
			echo "<td bgcolor=\"#00FF00\"  width=\"100\">From:   </td>";
			echo "<td bgcolor=\"#99CCFF\">$from</td>";
		  echo "</tr>";
		  echo "<tr>";
			echo "<td bgcolor=\"#00FFFF\"  width=\"100\">Subject:   </td>";
			echo "<td bgcolor=\"#CCFFFF\">$subject</td>";
		  echo "</tr>";
		  echo "<tr>";
			echo "<td bgcolor=\"#00FF00\"  width=\"100\">Message:   </td>";
			echo "<td bgcolor=\"#99CCFF\">$message</td>";
		  echo "</tr>";
		echo "</table>";
		echo "<br>";
		echo "<br>";
		echo "<br>";
		echo "<br>";
		echo "</center>";

}
}
?>

 

 

Ok so you can see i dont have a "Delete" Button up there, but when i had the the

 

else{

//code that deletes the message

}

 

it wouldnt work becuase it would right away delete the message the second i got to this page. How would i go about deleting a message, but only the message he click delete on.

 

Link to comment
https://forums.phpfreaks.com/topic/120973-deleting-a-row-in-mysqlit-doesnt-work/
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.