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 Link to comment https://forums.phpfreaks.com/topic/224372-generate-random-itemsnumbers-from-data-in-a-database/ 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 Link to comment https://forums.phpfreaks.com/topic/224372-generate-random-itemsnumbers-from-data-in-a-database/#findComment-1159150 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 Link to comment https://forums.phpfreaks.com/topic/224372-generate-random-itemsnumbers-from-data-in-a-database/#findComment-1159548 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. Link to comment https://forums.phpfreaks.com/topic/224372-generate-random-itemsnumbers-from-data-in-a-database/#findComment-1159553 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. Link to comment https://forums.phpfreaks.com/topic/224372-generate-random-itemsnumbers-from-data-in-a-database/#findComment-1160754 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.