MYSQL HowTo Get Display Select Show Data Starting With Letter Alphabet Only



MYSQL HowTo Get Display Select Show Data Starting With Letter Alphabet Only
 (380) Click. Work. Collect
MYSQL HowTo Get Display Select Show Data Starting With Letter Alphabet Only
Post Description:
Post Tags: mysql, howto, get, display, select, show, data, starting, with, letter, alphabet, only
This Post Has Been Viewed 1556 Times Since Wed Jan 10, 2007 12:01 pm Posted By braker with 2 replies
MYSQL HowTo Get Display Select Show Data Starting With Letter Alphabet Only
Today i was writing a PHP script and i couldn't figure out how to get the data from mysql and display it on with my code.

Can you guys help me.

basically i want to create links like this of all the my pages, and i want to display links with letters so people can click on them and will only display the pages starting with the letter. the links would show look like this alphabet:

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

then after a user click on the letter A (for example) i want to get all the pages starting with the letter A only, so i want to write the code for mysql so the it only gets the pages with starting with the letter A at the begining therefore only displaying the pages that begin with the letter A.

can you show me how to do get mysql data, and then display it on the screen with the mysql SELECT for my pages starting with a particular letter from the alpahbet only?

thanks

Leave Your Comments     [ dejar commentarios ]
  * Name     [nombre]

  * eMail (will not be published)     [coreo electronico]

* Enter Your Reply or Comments:    [commentarios]


Add Picture To Comments         [incluir foto]
YES NO             upload
Receive Replies on my Comments (An email will be sent to you when someone replies to your comments)

     

Comments and replies About MYSQL HowTo Get Display Select Show Data Starting With Letter Alphabet Only




:: 1 :: #161 - Reply By braker On Wed Jan 10, 2007 12:05 pm
to display your data from mysql database on an alphabetic pagination setup is easy.

I also read alot of forums but nothing gave me the answer, finally, i remembered this webiste, you can search wallpaper in alphebetical order by a specific letter only (starting with a certain letters in the alphabet)

For example, if you havea directory of services, and you want to have the links with the following letters: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

I will show you how to do this, if you are breaking my head trying to figure out how to do this, the answer is simple.

use the LIKE '$letter%' in mysql command:

So to show the data after a user click on a link with the letter, i will run the following mysql Select variable:


     Code:
$sql = "select $field from $table where $field like '$letter%' '";


that's it, the key here is
     Code:
like '$letter%'
- this is what makes all the magic happen

the '$letter%' tells mysql that i want anything that starts with the $letter.

so lets say i want only the data with the $letter at the begining, this would work fine

but how about if i wanted only the data with ending with the $letter, then i would use this:

     Code:
'%$letter'

NOTE: all i basically did was change the % to the beginning instead at the end.


Thanks to the folks at www.webune.com for their support, they were able to explain this to me.

If you need mysql / php hosting, we recommend you sign up with them, they are very helpful and have excellent support. the rely to my questions in no more than 15 minutes, i like that.
:: 2 :: #562 - Reply By Venam On Sat Feb 24, 2007 7:40 am
Can you write the whole code please?
Thank you!