dfowler Posted December 19, 2008 Share Posted December 19, 2008 Hey guys, I have created a database to list all my dvds for cataloging. However, I've run into a minor problem and I was hoping to get some help. For easy reference I am displaying all the dvds in alphabetical order by using the following code: <?php //Get dvds $query = "SELECT * FROM dvds ORDER BY title DESC"; $dvds = array(); $result = mysql_query($query) or die (mysql_error()); while ($row = mysql_fetch_assoc($result)){ $dvds[] = $row; } foreach($dvds as $d) { echo $d['title']."<br />"; } } ?> However, I am having a minor problem with articles. I would like to ignore "the", "a", "an", etc... and display everything in proper order. However, I'm not really sure how to do this. I don't want to strip the article off the title, just want to ignore it if it is the first word of the title. Thanks for any help! Link to comment https://forums.phpfreaks.com/topic/137731-solved-problem-with-the-or-a-etc/ Share on other sites More sharing options...
genericnumber1 Posted December 19, 2008 Share Posted December 19, 2008 http://ask.metafilter.com/52434/How-to-get-mySQL-to-ignore-A-An-amp-The-when-presenting-alphabetized-book-titles And it would be much more efficient to combine your loops. <?php //Get dvds $query = "SELECT * FROM dvds ORDER BY title DESC"; $dvds = array(); $result = mysql_query($query) or die (mysql_error()); while ($row = mysql_fetch_assoc($result)){ echo $row['title'].'<br />'; } } ?> Link to comment https://forums.phpfreaks.com/topic/137731-solved-problem-with-the-or-a-etc/#findComment-719939 Share on other sites More sharing options...
dfowler Posted December 19, 2008 Author Share Posted December 19, 2008 Thanks, I just threw the sort out like that for now. I'm eventually going to do a lot more with the dvds array, so that is why I am filling it that way. Thanks for your help! Link to comment https://forums.phpfreaks.com/topic/137731-solved-problem-with-the-or-a-etc/#findComment-719943 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.