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