Forum Moderators: coopster
[domain.com...]
[domain.com...]
[domain.com...]
...
where the "http://www.domain.com/folder/" is supplied by the querystring.
Here's what I have been able to compile from online sources and where I have gone horribly wrong.
<?php
function GetFileList($dirname, $extensoes = FALSE, $reverso = FALSE)
{
if(!$extensoes) // only list image files
$extensoes = array("jpg", "png", "jpeg", "gif");
$filenames = array(); // to store the file names without extensions
$files = array(); // to store the file names with extensions
$dir = getcwd() . "/";
$loc = Request.querystring("URL") // I don't know how to grab a query string variable
while(false!== ($file = readdir($dir)))
{
// only grab image files
for ($i = 0; $i < count($extensoes); $i++)
{
if (eregi("\.". $extensoes[$i] ."$", $file))
{
$filenames[] = $file - $extensoes // I need the file name separate from the extension
$files[] = $file;
}
}
}
// close the handle
closedir($dirname);
// arrange the files
if ($reverso) {
rsort($files);
} else {
sort($files);
}
for ($i = 0; $i < count($files); $i++)
{
// I need to print the results to the screen
echo "$loc$files,$filenames @br /@ \n";
}
}
?>
I appreciate any help, and I promise to go buy a PHP book as soon as possible! ;)
Actually there are two errors. The line you spotted and the other commented line at the top where I have no clue how to grab a querystring variable. (thus the VB line)
I'll take a look at 'substr', that's a Big help. Thanks!
This is all very confusing to me right now. I do all of my programming in ASP and have been thinking of learning PHP but I didn't expect to have to rush into it! ;)
btw, how does my 'echo' line look? I'm not sure what the '@br /@' do but this whole thing is pieces of things I found online to get me started.
echo "$loc$files,$filenames\n";
Someone told me PHP was easier than ASP, I don't know that I can argue one way or the other, but so far this script is about 1/3 smaller than the ASP version.
all I need now is to understand how to collect a variable form the querystring.
Thanks for all the help everyone
parse_url [ca.php.net]
$_GET superglobal array [php.net]
depends on how you are doing things
I love the title of this thread, made me laugh ;)
$thisQuery = $_SERVER["QUERY_STRING"];
$queryValue = explode("=",$thisQuery);
$loc = $queryValue[1];
I'm going to try this when I get a chance (I'm not where I can test things right now), but if it looks funny to anyone, let me know.
btw, I'm only passing one variable.
jatar - glad I made you laugh, I though it was a fairly true statement. Kinda felt like I was a little overwhelmed at first, but I'm picking it up.