Jump to content

HELP!! mysql_query


stekenno

Recommended Posts

Hello I have browsed this site many times looking for answers and it's helped alot but I couldn't find an answer for this problem.

 

I want messages to be displayed in the mail box to a certain amount say 25 and when a new mail is received the 26th one is then deleted.

 

$mysql1 = mysql_query("SELECT * FROM `inbox` WHERE `to`='$username' AND `read` = '1' ORDER by id DESC LIMIT 25");

 

 

$num_rows =mysql_num_rows($mysql1);

 

 

if ($num_rows == "0"){

 

 

echo "<center>No Messages</center>";

 

 

}else{

 

 

while($get = mysql_fetch_object($mysql1)){

 

 

mysql_query(DELETE * FROM `inbox` WHERE `to`='$username' AND `read` = '1' NOT IN (SELECT * FROM `inbox` WHERE `to`='$username' AND `read` = 1 ORDER by id DESC LIMIT 2));

 

THIS Part is the broken bit.

 

$t++;

 

 

$n++;

 

 

 

echo "

 

<table width=90% border=0 align=center cellspacing=0 class=messagetable>

Link to comment
https://forums.phpfreaks.com/topic/264386-help-mysql_query/
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.