|
||||||
| PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
From a MySQL database how can I randomly selected the data I use with mysql_query($query)?
I think that creating an array and using the rand() function is my only choice. This takes a lot of resources when I'm pulling 10,000 rows. Any Ideas?
__________________
DirkFirst |
| Sponsored Links |
|
|
|
|||||
|
you might be able to do this with a UNION
|
|
|||||
|
Just use the rand() function of MySQL.
Code:
SELECT * FROM tbl ORDER BY RAND() LIMIT 1;
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog The CodeCall Wiki is now fully integrated with vBulletin users! Check it out and add some new pages! |
|
|||
|
I don't know if I'm asking this in the right room but here it goes. Where do I put a random function If I am trying to make random links for articles on homepage show up in different areas.
|
|
|||||
|
If you want it on your homepage put it on your homepage. Are you using the mysql random function from above?
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog The CodeCall Wiki is now fully integrated with vBulletin users! Check it out and add some new pages! |
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Generating Random Numbers with PHP | Paradine | PHP Tutorials | 4 | 08-27-2007 08:09 PM |
| Return random numbers without duplicates | Paradine | PHP Tutorials | 0 | 08-26-2007 03:07 PM |
| How do I program a random generator? | eddiewillers | General Programming | 4 | 07-24-2007 03:26 PM |
| Code:PHP Random Functions | John | PHP Tutorials | 2 | 12-03-2006 11:04 AM |
| I need to generate a random number in PHP | dirkfirst | PHP Forum | 7 | 07-05-2006 10:58 PM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |
Goal: 100,000 Posts
Complete: 98%