Current location: Hot Scripts Forums » Programming Languages » PHP » trying to create my first simple (?) php script, need guidance


trying to create my first simple (?) php script, need guidance

Reply
  #1 (permalink)  
Old 09-06-04, 06:03 PM
HotShotPhoto HotShotPhoto is offline
New Member
 
Join Date: Sep 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Question trying to create my first simple (?) php script, need guidance

ok, so I am creating a Flash site with a dynamic gallery, and am loading the filenames into the swf from a temporary php file that I have created which is pretty much just a list of jpg filenames until I can write a php script that will list the filenames for me. Here is what the temporary php file I am using looks like, and what I need to emulate using script:
PHP Code:

<?php


echo &numoffiles=6// total number of jpegs in folder
echo &loading=no&    // tells the swf that the php is done loading

echo &img1=images/image1.jpg//these are the variables that I need to create dynamically
echo &img2=images/image3.jpg&
echo &
img3=images/anotherimage.jpg&
echo &
img4=images/thenextimeage.jpg&
echo &
img5=images/birds.jpg&
echo &
img6=images/lalalala.jpg&

?>
You can view the current gallery that works with that at Toddberk.com
This will be my first php script and I have went ahead and read the tutorial of php at http://www.w3schools.com/php/ . What I am looking for is some guidance on how I should go about accomplishing this, and some similiar examples if you could.
after searching for something similar in this forum I assume I will need to use functions like readdir. I don't know how to go about assigning each jpg file to a consecutive variable, or count all the jpgs in a folder. Could someone please let me know all the functions I need to use and how to use them. Everything will be appreciated.

Thanks,
Todd

P.S. hopefully this isn't too confusing, I like to type a lot.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 09-06-04, 09:12 PM
infinitylimit's Avatar
infinitylimit infinitylimit is offline
Code Guru
 
Join Date: Jun 2004
Location: Oregon
Posts: 758
Thanks: 0
Thanked 0 Times in 0 Posts
This is a little goofy but you would use a variable variable to make this work. Basically you want all the variable names to be of imgN format, that is where $$ this comes in. A short example http://www.phpbuilder.com/columns/robert20000928.php3

PHP Code:

$img 'img';

$i 1;
if (
$handle opendir('.')) {
   while (
false !== ($file readdir($handle))) {
       if (
$file != "." && $file != "..") {
         
$temp $img $i;
          $
$temp  $file;  //variable variable will be $img . $i as $img1 or ....
         
$temp null;
         
$i++;
       }
   }
   
closedir($handle);

That will do what you want as long as there are only image files in the directory.
__________________
Hawk Enterprises -- Home to PHP games, open-source code, tutorials and free downloads
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for a simple PHP login/register script Wheeler Script Requests 2 07-27-05 01:30 PM
simple free php hosting script Henry PHP 4 07-18-04 04:10 PM
I need a simple PHP script . . . willing to pay kacyl Script Requests 4 02-10-04 06:30 PM
Simple PHP script - any takers? zep Script Requests 2 01-28-04 09:12 PM
Need a simple php script jarod Script Requests 1 11-05-03 09:38 AM


All times are GMT -5. The time now is 10:40 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.