Unknown98 Posted January 13, 2011 Share Posted January 13, 2011 Hi, What I'm trying to do is create a script that generates a random list of cars whenever it is run. I have a list of available cars in a MySQL database. I'm just not sure how to get php to generate a list of, say, 20 cars, that are randomly picked from the cars in the database. I may also want to add other statistics like MPG (also already in the database). Can anyone show me how to do this? And is it possible to format the returned data in a table or div format? Thanks in advance Unk Quote Link to comment Share on other sites More sharing options...
litebearer Posted January 14, 2011 Share Posted January 14, 2011 1. a starting point - http://www.desilva.biz/mysql/random.html 2. yes, you can display the returned data is numerous ways - columns, rows, divs tables, lists etc etc Quote Link to comment Share on other sites More sharing options...
Unknown98 Posted January 14, 2011 Author Share Posted January 14, 2011 Well that was simple. I've got it working correctly now, formatted and everything. Thanks! Unk Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 14, 2011 Share Posted January 14, 2011 On large tables, ORDER BY RAND() can get very slow. Keep that in mind if things start to bog down. Quote Link to comment Share on other sites More sharing options...
Unknown98 Posted January 17, 2011 Author Share Posted January 17, 2011 Hmm, ok. It seems fine right now, but I do plan on adding many more cars to the cars DB in the future. Quote Link to comment 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.