Web Design Forum  
 
Go Back   Web Design Forum > Web Software > Scripts

Reply
 
LinkBack Thread Tools Display Modes
Old 10-09-2011, 07:58 PM   #1
New Member
 
Join Date: Oct 2011
Posts: 1
Default Displaying randomly chosen images.

I have a bit of a problem with the fact that i cant figure out how to stop the script from showing the same image several times.
I would love a little bit of help in this department :P I'm also curious if it's possible to use a faster way to choose the random
image since i know that "ORDER BY RAND()" is pretty slow. Thanks inbeforehand! =D


Here is my code.

PHP Code:
<?php
include "connect.php";

$result mysql_query("SELECT * FROM imgupload");
$count 0;
$num_rows mysql_num_rows($result);

echo 
"<br /><table id='gallerytable'><tr>";



while (
$count<=9)
{
    
$query mysql_query("SELECT id,text,location FROM imgupload ORDER BY RAND()");


    
$row mysql_fetch_row($query);
    
$kaboom explode("/",$row[2]);


    if (
$count %== 0)
        {
            echo 
"</tr><tr>";
        }
        
    echo 
"<td><a href='$row[2]' rel='lightbox[group]' title='$row[1]');><img src='$kaboom[0]/resized_$kaboom[1]'></a></td>";
    
$count ++;
}
    

?>
Nevermind i solved it :P

PHP Code:
<?php
include "connect.php";

$result mysql_query("SELECT id,text,location FROM imgupload ORDER BY RAND() LIMIT 5");
$count 0;
$num_rows mysql_num_rows($result);

echo 
"<br /><table id='gallerytable'><tr>";



while (
$count<=4)
{
    
$row mysql_fetch_row($result);
    
$kaboom explode("/",$row[2]);


    if (
$count %== 0)
        {
            echo 
"</tr><tr>";
        }
        
    echo 
"<td><a href='$row[2]' rel='lightbox[group]' title='$row[1]');><img src='$kaboom[0]/resized_$kaboom[1]'></a></td>";
    
$count ++;
}
    

?>

Last edited by yaci91; 10-09-2011 at 08:07 PM. Reason: Solved it.
yaci91 is offline   Reply With Quote


Reply

Tags
database, display random image, duplicate images, images, random

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 05:03 PM.


Camera Forum - Computer Forum - Web Design Forum

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO 3.6.0 ©2011, Crawlability, Inc.