sayen Posted October 14, 2011 Share Posted October 14, 2011 15 rows selected from the table. I want to randomly display an ad between them. Here's the code: $count = 1; (mysql select rows) $number = rand (1,15); if ($count == $number) { echo 'ad code '; } $count++; I want the ad to be displayed only once and in the above code, depending on the generated number by rand() matching the $number the ads will be displayed more times. How can I limit this only to one? Link to comment https://forums.phpfreaks.com/topic/249148-randomly-display-with-counting/ Share on other sites More sharing options...
requinix Posted October 14, 2011 Share Posted October 14, 2011 Pick your $number before the loop. Link to comment https://forums.phpfreaks.com/topic/249148-randomly-display-with-counting/#findComment-1279484 Share on other sites More sharing options...
sayen Posted October 14, 2011 Author Share Posted October 14, 2011 I knew that it was a simple thing. Works like a charm, thanks! Link to comment https://forums.phpfreaks.com/topic/249148-randomly-display-with-counting/#findComment-1279489 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.