Results 1 to 9 of 9

Thread: How do I make my PHP thing list in name order?

  1. #1
    Registered Member incka's Avatar
    Join Date
    Aug 2003
    Location
    Wakefield, UK, EU
    Posts
    3,801

    How do I make my PHP thing list in name order?

    How do I make my PHP thing list in name order?

    It's listing by ID autonumber, but I want to have them listed by name, what should I do...

    I'm only posting this cause I can't find Mike anywhere...

  2. #2
    Registered GCT13's Avatar
    Join Date
    Aug 2003
    Location
    NYC
    Posts
    480
    If you're querying your data from a database, put:

    order by name asc

    at the end of your sql query, where name is the name of the column you want to sort by. Are you using a database?
    ....

  3. #3
    Registered Mike's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    2,755

    Re: How do I make my PHP thing list in name order?

    Originally posted by incka
    I'm only posting this cause I can't find Mike anywhere...
    I've got flu
    Don't you just love free internet games ?

  4. #4
    Chronic Entrepreneur
    Join Date
    Nov 2003
    Location
    Tulsa, Oklahoma, USA
    Posts
    1,112
    Well cover your mouth when you type. I don't want to get sick!

  5. #5
    Registered Member incka's Avatar
    Join Date
    Aug 2003
    Location
    Wakefield, UK, EU
    Posts
    3,801
    Poor Mike...

    This is the code I'm using minus the log in details...


    PHP Code:
    <?php

    //connect
    $connect mysql_connect("localhost""dbname""password");

    //select db
    mysql_select_db("dbname"$connect);

    //query db
    $result mysql_query("SELECT * FROM games WHERE Category='Adventure'"$connect);

    //start table
    echo ("<table>");

    //list all games in table
    for ($x=0$x mysql_num_rows($result); $x++)
    {    
        
    $row mysql_fetch_assoc($result) ;

        echo (
    "<tr style='padding-top:10'>");
        echo (
    "<td><a href='http://www.games2go.co.uk/game/");
        echo 
    $row['URL'];
        echo (
    "'>");
        echo (
    "<img src='");
        echo 
    $row['ImageURL'];
        echo (
    "' border='0' width='70' height='59'>");
        echo (
    "</a>");
        echo (
    "</td>");

        echo (
    "<td style='padding-left:10'><font color='000000'><b>");
        echo (
    "<a href='http://www.games2go.co.uk/game/");
        echo 
    $row['URL'];
        echo (
    "'>");
        echo 
    $row['Name'];
        echo (
    "</font></a></b>");
        echo (
    ": ");
        echo 
    $row['Description'];
        echo (
    "</td></tr>");

    }

    ?>

  6. #6
    Registered GCT13's Avatar
    Join Date
    Aug 2003
    Location
    NYC
    Posts
    480
    incka, did you try my suggestion?

    Code:
    $result = mysql_query("SELECT * FROM games WHERE Category = 'Adventure' order by Name asc", $connect);
    ....

  7. #7
    Registered Member incka's Avatar
    Join Date
    Aug 2003
    Location
    Wakefield, UK, EU
    Posts
    3,801
    I'll try it now... Before when you posted it I didn't know where to put it, but i understand now... I'll try it out when I get to my computer... Thank you

  8. #8
    Registered
    Join Date
    Nov 2003
    Posts
    67
    The "order by ____ ASC or DESC" is what you need (as mentioned earlier).

    In case you're wondering, ASC is short for ascending and DESC is short for descending.

  9. #9
    Registered Mike's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    2,755
    Never knew that
    Don't you just love free internet games ?

Similar Threads

  1. Review: Professional PHP Programming
    By Chris in forum Books
    Replies: 6
    Last Post: 07-17-2013, 05:26 AM

Bookmarks

Posting Permissions

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