Re: reading records alphebetically

From: Date: Sun, 30 Dec 2001 20:56:22 +0000
Subject: Re: reading records alphebetically
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-55673@lists.php.net to get a copy of this message
You can either select the letter you want through mysql with "SELECT * FROM table WHERE name LIKE '$letter%' Or you can select everything: $result = mysql_query("SELECT * FROM table order by name"); while ($row = mysql_fetch_array($result)) { extract($row); $first_letter = strtolower($name[0]); } lets say $name = "Fred"; then $name[0] is set to "F"; $name[1] is set to "r"; $name[2] is set to"e"; and so on... ----- Original Message ----- From: "Jamie Saunders" <jamie.s@btinternet.com> To: <php-general@lists.php.net> Sent: Saturday, June 30, 2001 9:29 AM Subject: [PHP] reading records alphebetically > Hi, > > I have a MySQL database set-up containing a few hundred records. I'm trying > to make a script that reads the 'name' field of the records and displays > only the records of which the name field begins with a specific letter: > > if ($letter = A) { > display all records of which field 'name' beings with A > } else if ($letter = B) { > ... > > I'm just starting out on this, so please excuse my ignorance :) > > Jamie Saunders > jamie.s@btinternet.com > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#55673) next »