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

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']}%'";

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)?

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.