Stut wrote:
I have a sidebar on my site that gets a few random articles from that
table, prints the titles, small blurbs, and a link. The link goes to
the main article. I get the random IDs outside of mysql because I've
made it more likely for newer articles to be chosen than older
ones... This, accomplished via ID, because it's much easier to SELECT
count(*) and slant my randomization to the last 25% of ID numbers
than any other way I can think of...
Of course, this means that having holes results in empty sidebar
boxes... And that's not too good lookin...
How are you selecting random entries? A common way to do this is to
use the MySQL rand() function, but that is exceedingly slow.
I would suggest that you get a list of (or a subset of) the IDs in the
table, use PHP to randomly select however many you need and then get
the full data for those. You can't rely on the IDs, and the work
involved in resetting all the IDs such that they're sequential without
gaps is not worth it.
I use mt_rand(0,$max_rows) to get each of my values and send the call.
Getting an array of IDs sounds alright for now, but also sounds like it
gets increasingly slower and the table is expanded. I'll give it a try
though.
--
Mike Shanley
~you are almost there~
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php