Author Topic: div write onclick  (Read 255 times)

fmerg

  • New Member
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
div write onclick
« on: January 26, 2012, 08:14:51 AM »
help please...total newbie and lost
i have the following script that reads a folder on my server
converts it to a link
 
PHP Code: [Select]
<?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 
"<a href=$folder$file>$file</a>"."<br />"

?>


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: [Select]
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!-- A minimal Flowplayer setup to get you started -->
 

<!--
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>

</head><body>

<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>


</body></html>

if this cant be done please let me know

technobizzmo

  • New Member
  • *
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: div write onclick
« Reply #1 on: January 26, 2012, 10:49:58 PM »
Why not get the extension of the file?

PHP Code: [Select]
$info = new SplFileInfo('foo.txt');
var_dump($info->getExtension());

Sarthak Patel

  • Senior Member
  • ****
  • Posts: 368
  • Karma: +6/-0
    • View Profile
Re: div write onclick
« Reply #2 on: January 27, 2012, 12:06:26 AM »
Quote
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 Code: [Select]

//use this code
foreach ($files as $file)
 {
    
$filedetail =pathinfo($file); 
    if(
$filedetail['extension'] == 'flv')
    {
      echo 
'<a href="'.$folder$file.'" target="_blank">'.$file.'</a><br>';
    }



Instead of below code
PHP Code: [Select]

//Instead of below code
foreach ($files as $file) { 
    echo 
"<a href=$folder$file>$file</a>"."<br />"



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

fmerg

  • New Member
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: div write onclick
« Reply #3 on: January 27, 2012, 07:12:16 AM »
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

fmerg

  • New Member
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: div write onclick
« Reply #4 on: January 28, 2012, 06:26:59 AM »

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