dhimok Posted September 10, 2007 Share Posted September 10, 2007 Take a look at this loop. I am trying to limit the result to 5, but no help. Thats because the first loop has many results. Any idea how to limit the result <?php $sql = mysql_query("SELECT * FROM tbl_o WHERE id = '$id' ORDER BY rand() "); while($o = dbFetchObject($sql)) { $sql2 = mysql_query("SELECT * FROM tbl_o INNER JOIN tbl_p ON tbl_o.id = tbl_p.id WHERE nr = '".$o->nr."' ORDER BY rand() LIMIT 5"); while($p = dbFetchObject($sql2)) { echo $p->some_name; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/68753-check-this-out/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.