Page 1 of 1

Help with a movie library

Posted: Mon Jan 24, 2005 4:56 pm
by private-eye
Hi there guys!
I am very new to PHP, and i keep trying to follow tutorials, but I either loose interest, or dont understand.

For my site I would like to have my swf files in a folder i.e. mysite.com/files/flash/ and i would like to have videos in a different folder i.e. mysite.com/files/vids/ .

Anyway, I would like a php script that displays the names of those files in alphabetical order, with a discription, that links to a php file with the movie in it.

And on the front page i want it to display the 5 newest submittions.

I have no idea where to start and how to do this, can anyone help or point me in any direction, otherwise ill have to manually update it with html :-(

Thanks very much!

Posted: Mon Jan 24, 2005 5:01 pm
by feyd
here's how I've done this sort of thing:
  • modify a directory listing function to direct all of them to a script (either 1 for the whole site, or 1 for each image/video/audio type. Personally, I do one file for everything.)
  • use the same directory listing function to find the 5 or less most recently modified files (using filemtime())

opendir() | glob()

Posted: Mon Jan 24, 2005 5:09 pm
by private-eye
THANK YOU SO MUCH!!!!

I think I understand this a bit more now :S

Well anyway, thats a great help, thank you so so much!

Posted: Mon Jan 24, 2005 5:14 pm
by private-eye
With the

<?php
foreach (glob("*.txt") as $filename) {
echo "$filename size " . filesize($filename) . "\n";
}
?>

Thing, how do I make it link to the file?

Thanks!

Posted: Mon Jan 24, 2005 5:24 pm
by feyd
play with it.. you should figure it out quick.. ;)

Posted: Mon Jan 24, 2005 5:29 pm
by private-eye
erm... maybe you could start me off by telling me what a basic hyperlink code is in php ;) I only know html soz.


:)

Posted: Mon Jan 24, 2005 5:31 pm
by feyd

Code: Select all

echo "your html here.";
:P

Posted: Mon Jan 24, 2005 5:41 pm
by private-eye
<html>
<head>
<title></title>
</head>


<body bgcolor="#FFFFFF">
<?php
foreach (glob("*.txt") as $filename) {
echo "<a href="$filename.txt">$filename </a> size " . filesize($filename) . "\n";
}
?>

</body>


</html>


:S well that didnt work.

what did i do wrong?

it says on the page:

"Parse error: parse error, unexpected T_VARIABLE, expecting ',' or ';' in ----------------/text/index.php on line 10"

Posted: Mon Jan 24, 2005 5:43 pm
by feyd
double quotes require escapement when inside another double quote string.

i.e.

Code: Select all

echo "<a href="$filename.txt">$filename";