Jump to content

[SOLVED] mysql limit and delete


andyd34

Recommended Posts

Hi, Thanks for that but the issues isn't fetching the information its deleting it. I don't want to fill the database up with unwanted information.

 

for instance the db holds records 1 to 20. some visits the page and it holds records 1 to 21, i want to delete record 1. then someone else visits so its now 2 to 22, i want to delete record 2.

 

but thanx anyway

  • 2 weeks later...

HI and thanks for all your replies. I have now sorted the problem and just thught i'd post the solution I came up with

 


$sql = mysql-query("SELECT * FRON table WHERE column = 'something' AND Usr_ID = 'myid' LIMIT 0,20 ORDER BY date DESC");
while($row=mysql_fetch_assoc($sql)) {
$found[] = $row['id'];
### RESULTS HERE ###
}
mysql_query("DELETE FROM table WHERE id NOT IN (".implode(', ', $found).") AND Usr_ID = 'myid'");

 

Well it worked for me just thought it may come in usefull to someone else

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.