Jump to content

Archived

This topic is now archived and is closed to further replies.

MaartenM7

Alpabetical List

Recommended Posts

HI!

I got a problem...

I have a list of video items, they are automatically generated by a php script. All I have to do is put a video file into a directory and the video will apear on the website.

Now, this list of video's is unorderd... What means ít's a total mess. I want the script to put them in alfabetical order but I don't know how:(

Can anyone help me?

Thank you in advance,

Maarten Mandemaker, The Netherlands

Here's the piece of script:


---------------------------------------------------------------------------------------------------

<!-- 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="flvplayernl.swf?file=<?=$files[$file-1]?>&autoStart=false" />
<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>

Share this post


Link to post
Share on other sites
If you can get the filenames, or video names, into an array you can just use sort()"
[a href=\"http://us3.php.net/sort\" target=\"_blank\"]http://us3.php.net/sort[/a]
That will return the array but in alphabetical order. Anyway, any solution to this problem will most likely want to use arrays, so just use sort.

Share this post


Link to post
Share on other sites
Try this:

<?php
$sql = mysql_query(
"ALTER TABLE define ORDER BY word");

DEFINE should be replaced with your table name and WORD should be replaced by the column name you want alphabatized.

Hope that helps
(I use a script that allows the user to pick a letter of the alphabet and see only words starting with that letter, I can share if you would be interested)

Share this post


Link to post
Share on other sites
[!--quoteo(post=386925:date=Jun 22 2006, 02:33 PM:name=Buyocat)--][div class=\'quotetop\']QUOTE(Buyocat @ Jun 22 2006, 02:33 PM) [snapback]386925[/snapback][/div][div class=\'quotemain\'][!--quotec--]Anyway, any solution to this problem will most likely want to use arrays, so just use sort.[/quote]
Agreed. The [a href=\"http://ca.php.net/manual/en/function.glob.php\" target=\"_blank\"]glob() function[/a] can read a directory selectively and generate an array. Plenty of examples in the manual page referenced.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.