Fires of Heaven Guild Message Board  

Go Back   Fires of Heaven Guild Message Board > General forums > Development
User Name
Password
Or, use your gamerDNA username: (more...)
ForumSpy Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 04-25-2006, 11:21 PM   #1 (permalink)
aychamo_aycono
King Poster
 
aychamo_aycono's Avatar
 
Join Date: May 2002
Posts: 3,394
Quick PHP help

Hey guys,

I'm putting in an upload/download script for a specific function in a sub-dir of my webpage. It's just a script I found on the net. This is the the function of the script that lists the files in the download directory.

/************************************************** **********
* List Files
************************************************** **********/
$handle=opendir($upload_dir);
$filelist = "";
while ($file = readdir($handle)) {
if(!is_dir($file) && !is_link($file)) {
$filelist .= "".$file."";
if ($DELETABLE)
$filelist .= " x";
$filelist .= " ".date("d-m H:i", filemtime($upload_dir.$file))
."

";
$filelist .="
";
}
}

What I need to do, is where it lists the current files in the diretory, when it lists them, I want it to make a link to the same file .. So.. like where it says $filelist .= "".$file.""; or whatever, I need it to do small forum for discussion of medical topics.
aychamo_aycono is offline   Reply With Quote
Old 04-26-2006, 01:13 AM   #2 (permalink)
Morb
Registered User
 
Join Date: Jun 2002
Posts: 223
-1 Internets
Send a message via AIM to Morb
You concatenate strings with the period operator in php. i.e.

Code:
$filelist .= "<a href=\"" . $file . "\">" . $file . "</a>";
php is also capable of parsing unambiguous variables within double-quoted strings, so this works as well:

Code:
$filelist .= "<a href=\"$file\">$file</a>";
Personally, though, I avoid the latter method for clarity's sake.
Morb is offline   Reply With Quote
Old 04-26-2006, 08:01 AM   #3 (permalink)
aychamo_aycono
King Poster
 
aychamo_aycono's Avatar
 
Join Date: May 2002
Posts: 3,394
Hey Man!

That seems to make sense. You're totally right, the first way is a lot more readable and makes it make more sense.

Thank you!
Aychamo
__________________
I run a small forum for discussion of medical topics.
aychamo_aycono is offline   Reply With Quote
Reply


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 On
Trackbacks are On
Pingbacks are On
Refbacks are On
uberguilds network



All times are GMT -7. The time now is 01:06 AM.


Powered by vBulletin® Version 3.6.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0 RC6