DasHaas Posted August 1, 2007 Share Posted August 1, 2007 im sure this is an easy one to solve, but I cant seem to figure it out. Im got the ads to show but it shows all the ads in my database and is looks horrible. I would like to display only one ad at a time. here is my code: <?php $query = "SELECT HREF, SRC, ALT FROM PXS_Ads WHERE status = 1 and impressions_left>0 ORDER BY RAND()"; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); while ($row = mysql_fetch_object($result)) { $HREF = "$row->HREF"; $SRC = "$row->SRC"; $ALT = "$row->ALT"; ?> <table width="729" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td scope="col"><a href='<?php echo($HREF); ?>'><img src='<?php echo($SRC); ?>' name='<?php echo($ALT); ?>' border=0></a></td> <?php }//close while; //continue code ?> any elp would be greatly appreciated Quote Link to comment Share on other sites More sharing options...
DasHaas Posted August 1, 2007 Author Share Posted August 1, 2007 any takers? Quote Link to comment Share on other sites More sharing options...
Crew-Portal Posted August 1, 2007 Share Posted August 1, 2007 I would'nt know how to code this but use rand(0,9); and make each ad with an id from numbers 1 to 9. Whatever the number is get the mysql to pull that ad from the mysql and display it! Quote Link to comment Share on other sites More sharing options...
DasHaas Posted August 1, 2007 Author Share Posted August 1, 2007 i hope to eventually have lots of ads so i dont think the rand(0,9); will work unless I keep updating the code with the amount of ads that I have. Thanks a million for your help, i'll give it a shot anyway Quote Link to comment Share on other sites More sharing options...
DasHaas Posted August 1, 2007 Author Share Posted August 1, 2007 i figured it out! SELECT...FROM...WHERE...ORDER BY...LIMIT 1 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.