Jump to content


Photo

Alpabetical List


  • Please log in to reply
3 replies to this topic

#1 MaartenM7

MaartenM7
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 22 June 2006 - 05:38 PM

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>

#2 Buyocat

Buyocat
  • Members
  • PipPipPip
  • Advanced Member
  • 267 posts

Posted 22 June 2006 - 06:33 PM

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.
Looking for some easy-to-use tools?  Try these, https://sourceforge....jects/utils-php -- I made them myself.  They're distinct tools which are easy to understand and use.  See some examples uses at http://www.anotherearlymorning.com

#3 phpstuck

phpstuck
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 23 June 2006 - 01:17 AM

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)

#4 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 23 June 2006 - 01:21 AM

[!--quoteo(post=386925:date=Jun 22 2006, 02:33 PM:name=Buyocat)--][div class=\'quotetop\']QUOTE(Buyocat @ Jun 22 2006, 02:33 PM) View Post[/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.
Legend has it that reading the manual never killed anyone.
My site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users