SunQuest
           PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Try It Free
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old June 21st, 2002, 04:52 AM
eplummer eplummer is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Saratoga Springs, NY, US
Posts: 15 eplummer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 46 sec
Reputation Power: 0
Send a message via ICQ to eplummer Send a message via Yahoo to eplummer
Random Pictures from a directory

Hello All,

Does anyone know how to call random pictures from a directory. I can NOT use my MySQL database because it contains many more records than an individual directory. I want to call up 9 photos on one web page at random. Like each time the page is entered or refreshed?

Thanks
Ed Plummer
Saratoga Springs, NY

Reply With Quote
  #2  
Old June 21st, 2002, 04:57 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Random Pictures from a directory

Well, if you don't want to store the filenames in a database....you can read in the file names from the directory into an array, then shuffle the array, then use the first nine.....

If you already have these in a database, why not just put a where clause on it to limit to that subdirectory?


Reply With Quote
  #3  
Old June 21st, 2002, 05:37 AM
eplummer eplummer is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Saratoga Springs, NY, US
Posts: 15 eplummer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 46 sec
Reputation Power: 0
Send a message via ICQ to eplummer Send a message via Yahoo to eplummer
RE: Random Pictures from a directory

Thanks for the advice Anonymous.

I think the where statement would be very very long to sort out the photos I wanted for the random pictures.

I am not sure but I might have to put them in an array, then do as you said anyways. I am not good at this PHP anyway.

Just starting out and I have one hell of a job ahead of me in short order.

Thanks again,
Ed

Reply With Quote
  #4  
Old June 22nd, 2002, 04:31 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Random Pictures from a directory

Couldnt you just do something like this:
php Code:
Original - php Code
  1.  
  2. <?php   
  3. mysql_connect(HOST, USER, PASS) or die("Couldnt connect to database")
  4. mysql_select_db(DB) or die("Couldnt select database")
  5.     $result = mysql_query("SELECT * FROM `table` ORDER BY rand() LIMIT 9")
  6.     $row = mysql_fetch_array($result)
  7.              
  8.     echo "{$row['column']}<br>"
  9. ?> 

?

Reply With Quote
  #5  
Old June 22nd, 2002, 05:43 PM
sethadam1 sethadam1 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Orlando, FL
Posts: 223 sethadam1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Random Pictures from a directory

Try this code, just put your images into a directory, enter a few config variables, and you're off:

http://firsttube.com/display.php?file=random_image_generator_v2.php

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Random Pictures from a directory


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway