Smudly Posted June 14, 2010 Share Posted June 14, 2010 Hi, I am attempting to create a script that will give each row inside my database (each one contains a website url) a random value from 1 to the total number of rows in the table. Once each one is set, my script will go to the row with the value that has been set to 1. If that row's active status is == to Yes, and it's Credits > 0, the website will be selected to be shown to the user. If not, it will skip that row, and do the same checks for Row 2. I'm having difficulty figuring this out. Link to comment https://forums.phpfreaks.com/topic/204761-selecting-random-rows-and-setting-value-to-each-one/ Share on other sites More sharing options...
beta0x64 Posted June 14, 2010 Share Posted June 14, 2010 What are you having trouble with figuring out? It certainly sounds like you know what you want to accomplish. I would start out by working through your code in pseudocode. That is, connect to mysql connect to db if table not exists create table numrows = number of rows foreach row in table row = random_number() for i=0;i < numrows;i++ mysql(select status, credits from table where value = i) . . . then figure out what you need to work on to make it happen Link to comment https://forums.phpfreaks.com/topic/204761-selecting-random-rows-and-setting-value-to-each-one/#findComment-1071996 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.