Jump to content

[SOLVED] Problem with "the" or "a" etc


dfowler

Recommended Posts

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

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 />';
   }
}
?>

Archived

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

×
×
  • 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.