how to search in php by using alphabetic charecter in php i have code which show alphabetic like A to Z but how to search data by using thi alphabetic
code is below:-

<?php for ($i = 65 ; $i < 91 ; $i++) 
            printf ('<a href = "%s?result.php?$i=%s">%s</a> ', $PHP_SELF, chr($i), chr($i));


after use this code show A to Z Alphabetic but is search and select A then data show only A related from database but how to use in php i m not getting please some one Assist me and help me

Thank's In Advance
Rohit Tripathi

Edited by Dani: Formatting fixed

6 Years
Discussion Span
Last Post by twiss

First of all make your link proper, use common get parameter for all a to z links, Here i m using alpha get variable.

printf ('<a href = "%s?result.php?alpha=%s">%s</a> ', $PHP_SELF,chr($i) , chr($i));

Then in your result.php you query must look like

$query="select * from tablename where column like '{$_GET['alpha']}%'";

Edited by urtrivedi: n/a


That's not going to work, it should be $_GET[alpha]. (Edit: oops. Didn't notice the curly brackets.) Also, please use $_SERVER instead (it's safer), or even better, just the name of the current page. And why use printf at all (just asking)?

Edited by twiss: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.