Is there a way to limiting while loops when fetching data from mysql ?
$query = "SELECT *
FROM `table`
WHERE user_id = '$id'
ORDER BY `ID` DESC";
$result = mysql_query($query);
while ($info = mysql_fetch_assoc($result)) {
//stuff
}
Here i dont want to use mysql’s LIMIT function, can i limit while loop other than that one ?
Thanks
You can always
breakthe loop when it reaches its target. Otherwise you can use aforloop as Nick suggested.However note that it may be a better idea to limit the result-set from the query with the
LIMITcommand.