View Single Post
chappill
x10Hosting Member

chappill's Avatar

Join Date: Feb 2008
Posts: 74
Credits: 1,165
chappill is on a distinguished road
Quote  
09-25-2008, 02:59 AM
How to delete multiple MySQL rows...?

PHP Code:
PHP Code:
 $slavesel mysql_query("SELECT * FROM `slaves`");
$result mysql_num_rows($slavesel);
$randomdel rand(2,$result); 
</div> Is some code I have for selecting the rows from a table, counting them and randomizing them between 2 and the result.
What I have after that is:

<div class="code_header">PHP Code:
PHP Code:
$delete mysql_query("DELETE FROM slaves AMOUNT '$randomdel'"); 
But this doesn't work... It was a guess at it actually happening and much to my non suprisment... It didn't work. Is there anything like this that may work (Something that will delete an amount of rows randomly so instead of starting at 1 all the time it may start at row 34288 if there were that many).
I was thinking keep what I have at the top then below that have:

<div class="code_header">PHP Code:
PHP Code:
$rand2 rand(1,$randomdel); 
Then having:

<div class="code_header">PHP Code:
PHP Code:
$delete mysql_query("DELETE FROM slaves LIMIT $rand2, $randomdel"); 
All help will be much appreciated!
__________________
http://www.vpc-hack.net
The worlds best online hacking simulation game.
Reply With Quote
chappill is offlineReport Post