Jump to content

Random DISTINCT


phpretard

Recommended Posts

I only want to display only one disint image on a page at s time this... if you refresh sometimes shows 2

 

$result = mysql_query("SELECT DISTINCT image FROM ads ORDER by Rand() LIMIT 1");

while($row = mysql_fetch_array($result))
  {
  $ADimage=$row['image'];
  
  
  $echo= "<div align='center'><img src='ads/$ADimage'></div>";
  
  
  }

 

Any help tonight?

Link to comment
https://forums.phpfreaks.com/topic/120047-random-distinct/
Share on other sites

I think I screwed up my question.  I need 5 images to show up from the DB. If the same image is going to be displayed more than once (one the same page) than I would like to have a default  image its place.

 

Do you know what this means?

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /backup/hsphere/local/home/mercodesigns/mercodesigns.com/classifieds/pages/ads.php on line 6

Link to comment
https://forums.phpfreaks.com/topic/120047-random-distinct/#findComment-618401
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.