SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    May 2004
    Location
    NC
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Returning a MAX() value to php

    I want to return the maximum high score as a php variable, but I'm not sure how to structure the result. Here's the query:

    $query = "SELECT MAX(high_score) FROM tablename";
    $result = mysql_query ($query);

    And here's what isn't working (it's returning seemingly random numbers):
    $high_score = $result;

    What's the proper way to get the value? thanks--

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    698
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Code:
    $r = mysql_fetch_row($result);
    $high_score = $r[0];

  3. #3
    SitePoint Member
    Join Date
    May 2004
    Location
    NC
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks swampBoogie,

    I didn't know that you had to use mysql_fetch_row even when there was only one value being returned. I see now that it's just like an other query. thanks again-


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
  •