Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2006
    Location
    D?sseldorf
    Posts
    2,858
    Tokens
    2,256

    Latest Awards:

    Default URGENT - PHP not working..

    Basically, I have this code;

    <?php
    $query = "select *
    from `winningflight`
    order by points desc";
    $result = mysql_query($query) or die(mysql_error());
    $row = mysql_fetch_array($result);
    echo $row['flight'];
    ?>

    This is the table


    It always shows A, not B
    Last edited by Luke; 15-06-2013 at 11:26 AM.

  2. #2
    Join Date
    May 2007
    Posts
    10,481
    Tokens
    3,140

    Latest Awards:

    Default

    I personally can't see a problem with the code, maybe add limits. Also the MySQL bindings just got deprecated, you may want to use the MySQLi ones instead.
    Chippiewill.


  3. #3
    Join Date
    Nov 2006
    Location
    D?sseldorf
    Posts
    2,858
    Tokens
    2,256

    Latest Awards:

    Default

    Quote Originally Posted by Chippiewill View Post
    I personally can't see a problem with the code, maybe add limits. Also the MySQL bindings just got deprecated, you may want to use the MySQLi ones instead.
    I had a limit, but that didn't work:/ And I don't 100% know what that means

  4. #4
    Join Date
    May 2007
    Posts
    10,481
    Tokens
    3,140

    Latest Awards:

    Default

    "LIMIT 0,1" on the end of your mysql query will return just one result starting at the first result.
    Chippiewill.


  5. #5
    Join Date
    Nov 2006
    Location
    D?sseldorf
    Posts
    2,858
    Tokens
    2,256

    Latest Awards:

    Default

    I sorted it using MAX, but thanks Chippie!

  6. #6
    Join Date
    Oct 2006
    Posts
    9,905
    Tokens
    26,858
    Habbo
    Zak

    Latest Awards:

    Default

    In future (when your table gets a little more info) you may want to limit the query to the field names you want to return to optimise performance

Posting Permissions

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