div write onclick

help please…total newbie and lost
i have the following script that reads a folder on my server
converts it to a link
[php]<?PHP

$folder = “./”;
$handle = opendir($folder);

Making an array containing the files in the current directory:

while ($file = readdir($handle))
{
$files[] = $file;
}
closedir($handle);

#echo the files
foreach ($files as $file) {
echo “$file”."
";
}
?>[/php]

what i need is for this script to only list files with a flv extention

then when clicked change the following script that would be in a different div, iframe or new window

[code]

<!-- 
	include flowplayer JavaScript file that does  
	Flash embedding and provides the Flowplayer API.
-->
<script type="text/javascript" src="flowplayer-3.2.6.min.js"></script>

<!-- some minimal styling, can be removed -->
<link rel="stylesheet" type="text/css" href="style.css">

<!-- page title -->
<title>Minimal Flowplayer setup</title>
<div id="page">
	
	<p style="text-align: center">Frank and karen&#39;s website</p>
	
	<!-- this A tag is where your Flowplayer will be placed. it can be anywhere -->
	<a  
		 href="http://98.15.160.45/movies/"+ $file"
		 style="display:block;width:520px;height:330px"  
		 id="player"> 
	</a> 

	<!-- this will install flowplayer inside previous A- tag. -->
	<script>
		flowplayer("player", "http://98.15.160.45/movies/flowplayer-3.2.7.swf");
	</script>

	
	
	<!-- 
		after this line is purely informational stuff. 
		does not affect on Flowplayer functionality 
	-->

</div>
[/code]

if this cant be done please let me know

Why not get the extension of the file?

[php]$info = new SplFileInfo(‘foo.txt’);
var_dump($info->getExtension());[/php]

hi use below foreach loop code. Below code will check file extension. here i am it's checking that if extension is flv than it will display that link. When link is clicked it will open in new window.

[php]
//use this code
foreach ($files as $file)
{
$filedetail =pathinfo($file);
if($filedetail[‘extension’] == ‘flv’)
{
echo ‘’.$file.’
’;
}
}
[/php]

Instead of below code
[php]
//Instead of below code
foreach ($files as $file) {
echo “$file”."
";
}
[/php]

I hope this will helpful for you
Reply your feedback.
~SR~

hey thanks
this helpped a lot
just for your info i have not done any programing at all… ever!
just at this for two weeks trying to learn java html and php all at the same time for one what i thought would be a simple project

Parse error: syntax error, unexpected T_VARIABLE, expecting ‘,’ or ‘;’ in E:\franks\test\filelist.php on line 10

Sponsor our Newsletter | Privacy Policy | Terms of Service