Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-27-2005, 10:22 PM   PM User | #1
simjay
Regular Coder

 
Join Date: Jul 2005
Posts: 153
Thanks: 1
Thanked 0 Times in 0 Posts
simjay is an unknown quantity at this point
Display Random

Here is my code, i need it to display 1 entry from the database randomly? And ideas. As you can tell im a newbie

PHP Code:
  <?php
        $sql 
"SELECT * FROM banner";
            
$result mysql_query($sql$conn) or die(mysql_error());
                while (
$newArray mysql_fetch_array($result)) {
                    
$banner_id $newArray['banner_id'];
                    
$banner_dir $newArray['banner_dir'];
                    
$banner_bussiness $newArray['banner_bussiness'];
                    
$banner_website    $newArray['banner_website'];
            echo 
"<a href='$banner_website'><img src='banner/$banner_dir' alt='$banner_bussiness' border='0' height='60px' width='468px'></a>                ";
        }
?>
simjay is offline   Reply With Quote
Old 08-27-2005, 10:35 PM   PM User | #2
marek_mar
Sensei


 
Join Date: Aug 2003
Location: One step ahead of you.
Posts: 2,815
Thanks: 0
Thanked 3 Times in 3 Posts
marek_mar is on a distinguished road
SELECT * FROM foo ORDER BY RAND() LIMIT 1
__________________
I'm not sure if this was any help, but I hope it didn't make you stupider.

Experience is something you get just after you really need it.
PHP Installation Guide Feedback welcome.
marek_mar is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:23 PM.


Advertisement
Log in to turn off these ads.