php sorting through mysql

Sharky Forums


Results 1 to 6 of 6

Thread: php sorting through mysql

  1. #1
    Tiger Shark Muk108's Avatar
    Join Date
    Feb 2002
    Location
    Ohio
    Posts
    868

    php sorting through mysql *resulved*

    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?
    Last edited by Muk108; 09-22-2003 at 04:22 PM.
    WHy...why...

  2. #2
    Hammerhead Shark
    Join Date
    Feb 2001
    Location
    Columbus, Ohio
    Posts
    1,277
    I've been trying to figure this out. I started looking through PhpMyAdmin's code. in sql.php I found:

    PHP Code:
    $sql_limit_to_append " LIMIT $pos, ".$cfg['MaxRows']; 

    So I'm guessing it's something like:

    PHP Code:
    "SELECT * from users ORDER BY username LIMIT 11, 10" 
    I'm bout to go to bed or I would test it.

  3. #3
    Tiger Shark Muk108's Avatar
    Join Date
    Feb 2002
    Location
    Ohio
    Posts
    868
    i know how to do it throught sql i just want the php for the users to choose what they want...
    WHy...why...

  4. #4
    Hammerhead Shark
    Join Date
    Feb 2001
    Location
    Columbus, Ohio
    Posts
    1,277
    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.

  5. #5
    Tiger Shark Muk108's Avatar
    Join Date
    Feb 2002
    Location
    Ohio
    Posts
    868
    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?
    WHy...why...

  6. #6
    Tiger Shark Muk108's Avatar
    Join Date
    Feb 2002
    Location
    Ohio
    Posts
    868
    i found a better way of doing it....


    PHP Code:
    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.
    WHy...why...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •