doyle007
asked on
Build dynamic links
Hey guys,
I'm trying to do something I can normally do in C language, but in PHP and having some issues. Might be my C way of thinking!
Basically, I'm scanning a directory for filenames, and then I want to dynmiacially build a html link with that filename in it...But, I need to save the value as $_SESSION[] info so I can use it in the next page that the link refers too...if that makes sense...
I'm trying to do something I can normally do in C language, but in PHP and having some issues. Might be my C way of thinking!
Basically, I'm scanning a directory for filenames, and then I want to dynmiacially build a html link with that filename in it...But, I need to save the value as $_SESSION[] info so I can use it in the next page that the link refers too...if that makes sense...
$handle ="";
$count=0;
if ($handle = opendir('../videos'))
{
while (false !== ($file = readdir($handle)))
{
if (($file == ".") || ($file == "..")) { continue; };
if (stripos($file, "flv"))
{
//in C i can append an integer (with some work) to the end of a variable name. So each iteration of the loop the variable will be called $link1, $link2, $link3 and so on.
$link.$count = $file;
$count++;
}
}
}
closedir($handle);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I know that the $link.$count was saving nothing...in C you can append an int (convert it to string fist) to a variable by using sprintf so the variable would be
$link1 =
$link2 =
$link3 =
then I could use $link1 or $link2 where I please....is a bit diff in php....cheers.
$link1 =
$link2 =
$link3 =
then I could use $link1 or $link2 where I please....is a bit diff in php....cheers.
ASKER
Open in new window
Then I just do this in the next page
Open in new window