1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need help

Discussion in 'PHP' started by andts19, Oct 17, 2005.

  1. #1
    Hi all,

    I am new in php and I need help. I have a web-site which contains .pdf files. Every week I add a .pdf file and at the moment I update the site manually (go to the source code and change the source names etc). I would like to ask if there is any way, for the site to be updated automatically. e.g. When I add the .pdf file in the directory, the site will be automatically updated with the specific .pdf file. Is there any script that I can create in order to do that. Thanks a lot in advance. If you need more info of what i want to do or if somethink is uncleared pls let me know.


    Thanks
    Andts19
     
    andts19, Oct 17, 2005 IP
  2. nevetS

    nevetS Evolving Dragon

    Messages:
    2,544
    Likes Received:
    211
    Best Answers:
    0
    Trophy Points:
    135
    #2
    Something like this might help. It should be at least enough to get you started.

    
    $myDir = opendir("./");
    while(false !== ($tmpstring = readdir($myDir)))
    	{
    		$dirlisting[$i] = $tmpstring;
                    $i=$i+1;
    	}
    arsort($dirlisting);
    while(list($key,$fileName) = each($dirlisting))
    {
    if (($fileName != ".")&&($fileName != ".."))
     echo '<a href="http://www.yoursite.com/pdfs/'.$fileName.'">'.$filename.'</a>';
    }
    
    PHP:
     
    nevetS, Oct 17, 2005 IP
  3. durango

    durango Guest

    Messages:
    83
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    nevetS,

    Any preference in using:
    while(list($key,$fileName) = each($dirlisting))
    Code (markup):
    And not:
    foreach ( $dirlisting as $key => $fileName )
    Code (markup):
    Just curious... I usually use the second, as I belive (maybe I'm wrong) that it is less overhead. Less function calls. Or do you think when the code is parsed, it would execute the same amount of instructions to do either?
     
    durango, Oct 17, 2005 IP
  4. nevetS

    nevetS Evolving Dragon

    Messages:
    2,544
    Likes Received:
    211
    Best Answers:
    0
    Trophy Points:
    135
    #4
    I never put much thought into it. I use either on occasion. I'm pretty sure I grabbed this code from someone else a couple of years ago.
     
    nevetS, Oct 18, 2005 IP