Plz Help with Script
Posted: Sat May 06, 2006 10:35 pm
feyd | Please use
Someone plz help I just dont know what 2 do....?? I have no problem including the picture, just the random part, once I have the filename im good but Ive always used an array for random so im lost picking a random file from a folder.
help plzz
Kendra A
feyd | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
OK someone plz save me
Ive been assigned to helping build paintboard.ca and im already stuck We need to be able to show random pics from the database so I need a php script that will look in a folder for any .htm files and pick one at random.
The pictures are all converted to .htm are numbered in ordered numeric sequence such as 100.htm, 101.htm, 102.htm when they are saved.
The best I can come up with is this playing with perl but I would much rather use php, as I can incude it much easier in the page, and wont need a cgi-bin
[syntax="perl"]#!/usr/bin/perl
#----------------------------------
# RANDOM PAGE BETA1.0
# Kendra Adams
#----------------------------------
$base_url = "/db/";
$datapath = "/localhost/paintboard/db/";
$align = "left";
$border = "1";
print "Content-type: text/html\n\n";
# Search Directory for htm or html Files
opendir (FILELIST, "$datapath");
rewinddir (FILELIST);
@dirlist = grep(!/^\.\.?$/, readdir (FILELIST));
closedir (FILELIST);
$num_in_dir = @dirlist; # the number of items in @dirlist
$counter = 0;
while ($num_in_dir > $counter) {
@check = split(/\./, $dirlist[$counter]);
if ($check[1] =~ /jpg/i || $check[1] =~ /gif/i){
push (@files, $dirlist[$counter]);
}
$counter++;
}
srand(time ^ $$);
$num = rand(@images)
print qq~
<img src="$base_url$images[$num]" border=$border align="$align">
~;
exit;help plzz
Kendra A
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
feyd | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]