Quote (eagl3s1ght @ Aug 4 2012 02:22pm)
Carteblanches' code should work fine. Can you paste the complete script that you used when every sites rank got set to 7?
<?php
include('config2.php');
$sql = "SELECT * FROM sites ORDER BY views DESC";
$result = mysql_query($sql) OR die(mysql_error());
$total = mysql_num_rows($result);
echo $total;
$i = 1;
while ($row = mysql_fetch_assoc($result)){
$i++;
$siteid = $row[site_id];
$update = "UPDATE sites SET rank=$i where site_id=$siteid" ;
$result = mysql_query($update);
}
?>
This "works" for the first site. First site get's set rank 1, but all the other sites get set to rank 7 :/ It's as if the WHILE runs, but does not update the RANK field on every pass, and updates every row except the first one when it is "finished" and $i=7
This is breaking me :')