Reply
making lists alphabetical
Old 03-14-2006, 06:05 PM making lists alphabetical
Extreme Talker

Posts: 171
I use the following script to scan a folder to look for .flv and creat a playlist the problem is that the list is not alphabetical. Here is the coding i use. Here is an example http://video.somplanet.com/

PHP Code:
<?php

//-----------------------------------------------------------------------------------------
// the variables you have to set
//-----------------------------------------------------------------------------------------

// width of the video
$width 320;

// height of the video
$height 240;

//-----------------------------------------------------------------------------------------
// rest of the php part 
//-----------------------------------------------------------------------------------------

// autoscanning the flv directory
@$d dir("flv");
if (
$d) { 
    while(
$entry=$d->read()) {  
        
$entry preg_replace("/ /","%20",$entry);
        
$pos strpos(strtolower($entry), ".flv");
        if (!(
$pos === false)) {  
            
$files[] = "flv/".$entry
        } 
    }
    
$d->close();
}

// getting the file from the url
if ($_GET['file']) { $file $_GET['file']; } else { $file 1; }

// extracting the name of the video
$p1 strrpos($files[$file-1],"/") + 1;
$p2 strpos($files[$file-1],".flv");
$name substr($files[$file-1],$p1,($p2-$p1));

//-----------------------------------------------------------------------------------------
// displaying the html page
//-----------------------------------------------------------------------------------------
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>FLV Player Playlist</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />


<!-- Stye Sheet -->
<style type="text/css">
  body { background-color: #eeeeee; font:10px/16px verdana; color: black; } 
  a { color: black; }
  a:hover { color: #cc0000; }
  div { margin:20px; }
  h1 { margin-left:30px; }
</style>


</head>
<body>


<!-- the flv movie name -->
<div id="name">
    <h1><?=$name?></h1>
</div>


<!-- the flvplayer -->
<div id="player">
    <object type="application/x-shockwave-flash" data="flvplayer.swf?file=<?=$files[$file-1]?>
        width="<?=$width?>" height="<?=$height?>" wmode="transparent">
          <param name="movie" value="flvplayer.swf?file=<?=$files[$file-1]?>" />
          <param name="wmode" value="transparent" />
    </object>
</div>


<!-- the navigation -->
<div id="nav">
    <ul>
    <? // php loop for printing all the links
    
for ($i=0$i<=sizeof($files)-1$i++) {
        
$p1 strrpos($files[$i],"/") + 1;
        
$p2 strpos($files[$i],".flv");
        
$name substr($files[$i],$p1,($p2-$p1));
        echo 
"        <li><a href=\"flvplayer.php?file=".($i+1)."\">".$name."</a></li>\n";
    } 
?>
    </ul>
</div>


</body>
</html>
mohamoud is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 03-15-2006, 12:57 AM Re: making lists alphabetical
vangogh's Avatar
Post Impressionist

Posts: 8,820
Name: Steven Bradley
Location: Boulder, Colorado
You can try running sort(); on your array before displaying it.
__________________
l Search Engine Friendly Web Design | Van SEO Design
l Tips On Marketing, SEO, Design, and Development | TheVanBlog
l Custom WordPress Themes
| Small Business Forum
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 03-15-2006, 06:58 PM Re: making lists alphabetical
Extreme Talker

Posts: 171
I am lost I would i use the sort function. I am new to php
mohamoud is offline
Reply With Quote
View Public Profile
 
Old 03-15-2006, 11:36 PM Re: making lists alphabetical
vangogh's Avatar
Post Impressionist

Posts: 8,820
Name: Steven Bradley
Location: Boulder, Colorado
I'm not quite sure what you're asking. sort() will sort the array in alphabetical order so if you add the code:

sort($files);

before the for loop in your code above it will place all of the values in the $files array in alphabetical order like you want. Let me know if that works or if you need more help.
__________________
l Search Engine Friendly Web Design | Van SEO Design
l Tips On Marketing, SEO, Design, and Development | TheVanBlog
l Custom WordPress Themes
| Small Business Forum
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 03-16-2006, 06:33 PM Re: making lists alphabetical
Extreme Talker

Posts: 171
It makes the list alphabetical. But it plays the wrong video.
mohamoud is offline
Reply With Quote
View Public Profile
 
Old 03-16-2006, 11:23 PM Re: making lists alphabetical
vangogh's Avatar
Post Impressionist

Posts: 8,820
Name: Steven Bradley
Location: Boulder, Colorado
Sorry. I didn't see that you were using the array in your code for the flvplayer. Where did you add the sort() code? I think it just needs to be before the flvplayer code.

Try putting it much closer to the top just before:

// getting the file from the url
if ($_GET['file']) { $file = $_GET['file']; } else { $file = 1; }


and see if that works.
__________________
l Search Engine Friendly Web Design | Van SEO Design
l Tips On Marketing, SEO, Design, and Development | TheVanBlog
l Custom WordPress Themes
| Small Business Forum
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 03-17-2006, 03:32 PM Re: making lists alphabetical
Extreme Talker

Posts: 171
It worked.
mohamoud is offline
Reply With Quote
View Public Profile
 
Old 03-17-2006, 05:58 PM Re: making lists alphabetical
vangogh's Avatar
Post Impressionist

Posts: 8,820
Name: Steven Bradley
Location: Boulder, Colorado
Cool. I just checked the page and it's looking good. Glad it all worked out.
__________________
l Search Engine Friendly Web Design | Van SEO Design
l Tips On Marketing, SEO, Design, and Development | TheVanBlog
l Custom WordPress Themes
| Small Business Forum
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Reply     « Reply to making lists alphabetical
 

Thread Tools

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 Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.15809 seconds with 12 queries