Jump to content

Alpabetical List


MaartenM7

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>
Link to comment
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.
Link to comment
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)
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.