MaartenM7 Posted June 22, 2006 Share Posted June 22, 2006 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 NetherlandsHere'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 linksfor ($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> Quote Link to comment https://forums.phpfreaks.com/topic/12654-alpabetical-list/ Share on other sites More sharing options...
Buyocat Posted June 22, 2006 Share Posted June 22, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/12654-alpabetical-list/#findComment-48555 Share on other sites More sharing options...
phpstuck Posted June 23, 2006 Share Posted June 23, 2006 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) Quote Link to comment https://forums.phpfreaks.com/topic/12654-alpabetical-list/#findComment-48669 Share on other sites More sharing options...
AndyB Posted June 23, 2006 Share Posted June 23, 2006 [!--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. Quote Link to comment https://forums.phpfreaks.com/topic/12654-alpabetical-list/#findComment-48671 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.