Hello Everyone

iam making a search file that retrieve data from database by letters

i got this code

SELECT `name`
FROM users
WHERE `name` LIKE 'A%'

it show the data that begin with letter (( A ))

Ok my main page now contain this letter

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 made a stupid way to get the data

i made a page for every letter contain the code to get the data

this mean a.php b.php and so on

i know there's an easy way to make one search file lets say

Search.php?letter=a

how can i do that

To do this in a simple manner:

if ( isset( $_GET['letter'] ) ) {
  $query = mysql_query("SELECT `name` FROM `users` WHERE `name` LIKE '" . mysql_real_escape_string( strtoupper( $_GET['letter'] ) ) . "%'");
  //do what you want with query result
}
commented: Thanks Sir +2

Thanks Sir Iam Gonna Try It

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.