phpretard Posted August 17, 2008 Share Posted August 17, 2008 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? Quote Link to comment Share on other sites More sharing options...
marcus Posted August 17, 2008 Share Posted August 17, 2008 Why not just $sql = "SELECT image FROM `ads` ORDER BY RAND() GROUP BY image LIMIT 1"; or even drop the group by. Quote Link to comment Share on other sites More sharing options...
phpretard Posted August 17, 2008 Author Share Posted August 17, 2008 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 Quote Link to comment Share on other sites More sharing options...
marcus Posted August 17, 2008 Share Posted August 17, 2008 Ok, this means you have a mysql error. mysql_query(QUERY) or die(mysql_error()); just try this $sql = "SELECT image FROM `ads` ORDER BY RAND() LIMIT 1"; Quote Link to comment Share on other sites More sharing options...
phpretard Posted August 17, 2008 Author Share Posted August 17, 2008 Sorry about the confusion. Quote Link to comment Share on other sites More sharing options...
phpretard Posted August 17, 2008 Author Share Posted August 17, 2008 I have searched and searched and found some thing about cookies and sessions and now my brain hurts. Anymore thoughts here? 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.