[Solved] Limit in MySQl statement not working
Posted: Thu Dec 22, 2005 7:17 pm
ok here is the code
It seems to be dropping the first record and only increment to four records. I tried $limit = $numRows +1; and all that did was skip the first record in the fetch and add to 5 preceeding records.
WTF anyone know whats up with this little bug? How to work around it?
thanks,
Code: Select all
$order='ASC';
$numRows =5;
if ($_SERVER['HTTP_CONNECTION']){
$limit = $numRows ;
$query_id_rs = "SELECT id FROM textads WHERE visible='y' AND active='y' ORDER BY date_created ".$order." LIMIT ".$limit."";
$id_rs = mysql_query($query_id_rs, $db_connect) or die(mysql_error());
$all_visible_ids = mysql_fetch_assoc($id_rs);
while($all_visible_ids = mysql_fetch_assoc($id_rs)){
$sql_query = 'UPDATE textads SET view_count = view_count+1 WHERE id="'.$all_visible_ids['id'].'"';
mysql_query($sql_query, $db_connect) or die(mysql_error());
// for testing
//print_r($all_visible_ids);
}
}WTF anyone know whats up with this little bug? How to work around it?
thanks,