Hi, I found a php snippet bellow through google and it works fine in picking up results at random. However, some time the results is smaller than I wanted it be, and some times as bad as 1 result. $count = mysql_query("SELECT count(*) FROM featured"); $sql = mysql_fetch_row($count); $random = mt_rand(0,$sql[0] - 1); $result = "mysql_query("SELECT id, name FROM featured LIMIT $random, 12") Code (markup): How could I always get 12 results out of the random? Thanks in advance
Would need to see more of the search code, for example are you searching for exact "word" or have you tried using words like "%word%" witch is a wild card or words within words, you can mix that as-well like "word%" so it grabs the beginning word plus anything else ending like "wording" Its just another way to get more results and your code above will always limit to 12 regardless word = word %word% = any wording word% = wording %word = any word
you switch the arguments of the limit clause, it should be $result = "mysql_query("SELECT id, name FROM featured LIMIT 12, $random")
No, this ain't good. The result sometime come out more than 12. My web page design fits for 12 items or static result, other wise it would look ugly.