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

RegisterLogin
MYSQL HowTo Get Display Select Show Data Starting With Letter Alphabet Only
Post Description: MYSQL HowTo Get Display Select Show Data Starting With Letter Alphabet Only
Tags: MYSQL, HowTo, Get, Display, Select, Show, Data, Starting, With, Letter, Alphabet, Only
This Post Was Posted On Feb 29, 2008 By braker #1469
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
Related Pages: [Add Your Website]
Post New Topic
Venam
#1897 1
Can you write the whole code please?
Thank you!
Feb 24, 2007 Reply Report abuse
braker
#1896 2
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.
Jan 10, 2007 Reply Report abuse
©2011 Webune Forums - Sun Dec 18, 2011 4:49 pm
Powered by: Webune Forums V3