Click to See Complete Forum and Search --> : php sorting through mysql
Muk108
09-21-2003, 10:40 PM
how can i get my page to sort through data alphabeticly(sp) and with a limit on how many results it can display and then to top it off go to the next page of results if nessasary? i know how to do it in mysql but i dont know how to make a page out of this. can someone help me out?
anfpunk
09-21-2003, 10:58 PM
I've been trying to figure this out. I started looking through PhpMyAdmin's code. in sql.php I found:
$sql_limit_to_append = " LIMIT $pos, ".$cfg['MaxRows'];
So I'm guessing it's something like:
"SELECT * from users ORDER BY username LIMIT 11, 10"
I'm bout to go to bed or I would test it.
Muk108
09-21-2003, 11:58 PM
i know how to do it throught sql i just want the php for the users to choose what they want...
anfpunk
09-22-2003, 10:04 AM
If that works then just use $_GET variables and set the limit with variables in the MySQL query. The MySQL query is the hard part.
Muk108
09-22-2003, 04:03 PM
would it be something like...
$sql = "select * from alumni ORDER BY alumni_name ASC WHERE(alumni_name BETWEEN " . "a"/*$_GET['ltr']*/ . " AND " ."a"/* $_GET['ltr'] */. ") LIMIT 0 , 20";
would it be something like that?
Muk108
09-22-2003, 04:22 PM
i found a better way of doing it....
if ($sltr=="") {
if ($_GET['sltr']=="") {
$sltr = "a";
} else {
$sltr = $_GET['sltr'];
}
if ($_GET['eltr']=="") {
$eltr = "z";
} else {
$eltr = $_GET['eltr'];
}
$sql = "SELECT * FROM alumni WHERE(alumni_name BETWEEN '" . $sltr . "' AND '" . $eltr . "')" . "ORDER BY alumni_name ASC" ;
}
thanks for the input there. now just to get the page number display.