View Full Version : Alphabetical
TMLewiss
12-07-2003, 09:11 AM
Ok, I'm createing a huge database that stores massive amounts of users. Then I have a page that will display them in Alphabetical order. How do I do this. I only need to know how to display them in that order. Also I want it to just display A if I click a, then B if b, and all odd characters and numbers when I hit something like "Other". Thanks in advance for any help
Welcome here.I only need to know how to display them in that order
$sql = "SELECT var1, var2, usernamevar FROM usertable ORDER BY usernamevar ASC" ;
Also I want it to just display A if I click a, then B if b, and all odd characters and numbers when I hit something like "Other".
Your links need to look like
<a href="searchpage.php?start=a" title="All names starting with 'a'">a</a>
Inside searchpage.php; you then have
$sql = "SELECT var1, var2, usernamevar FROM usertable WHERE usernamevar LIKE '" . $_GET['start'] . "%' ORDER BY usernamevar ASC" ;
But you best run some checks on the querystringvariable, like if the length isn't more then 1
if (strlen($_GET['start'] <=1)
or that it isn't % or other wildcards (which would probably crash your server if i run it 10 times.) The querystringvalue shoulfd probably always by an alfanumerical value. (use a regex to check against that)
Having the user include other then alphabetic characters is very dangerous + are ther so many names that start with none alfanumeric characters.
Anyhow, i would always include a LIMIT clause to prevent that big recordsets are retrieved + displaying a "massive amounts of users" is pointless. Noone browses through them so you better have a more efficient search (including the first x letters for instance)
vBulletin® v3.8.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.