Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 31

Thread: Ordering by highest value

  1. #11
    Join Date
    Sep 2003
    Posts
    603
    Rep Power
    0

    Default

    change the query to
    Code:
    $query = "SELECT side, twins + ' ' + tloses AS stats FROM summary ORDER BY twins ASC";
    easiparcel.com Shop online and ship to Jamaica

  2. #12
    Join Date
    May 2004
    Posts
    530
    Rep Power
    0

    Default

    Thanks for your quick response. That error is taken care of but now i am getting this error:

    Parse error: syntax error, unexpected T_WHILE in /home/www//wcc/score.php on line 15
    this is line 15:
    while($result = mysql_fetch_assoc($result)){

    Any ideas.
    "...men are that they might have joy."
    Nephi

  3. #13
    Join Date
    Oct 2005
    Posts
    745
    Rep Power
    0

    Default

    Quote Originally Posted by leocrawf View Post
    This is what i have so far , but i am getting a error with the sql please take a look:

    <?php

    include_once("conn.php");

    $f = ($_GET["f"]);
    $query = "SELECT side, CONCAT(twins, " ", tloses) AS stats, FROM summary ORDER BY twins ASC";
    $result = mysql_query($query) or die(mysql_error());
    $numR = mysql_num_rows($result);
    if ($numR = 1) {
    echo"success=1";
    $statsarray = array();
    $sidearray = array();
    $x = 0 ;// array index
    //collect returned results in associtive manner
    while($result = mysql_fetch_assoc($result)){
    $statsarray[$x] = $result['stats'];
    $sidearray[$x] = $result['side'];
    $x++;
    }
    //to display

    $loopcontrol = count($side);

    for($a = 0; $a<$loopcontrol; $a++){
    echo $sidearray[$a] . " " . $statsarray[$a];
    }
    }
    else
    {
    echo( "success=0" );
    }

    // Clean up
    mysql_close($dblink);

    ?>

    Now the error i am getting is this:

    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/www//score.php on line 6.
    This is line 6:
    $query = "SELECT side, CONCAT(twins, " ", tloses) AS stats, FROM summary ORDER BY twins ASC";

    As for as i can figure the sql looks good but i am getting this error.
    You might be missing a semi-colon.
    3.14159265358979323846264338327950288
    4197169399375105820974944592307816406
    28620899862803482534211706798 pi 101

  4. #14
    Join Date
    May 2004
    Posts
    530
    Rep Power
    0

    Default

    OK. NOW THIS IS WHAT I AM GETTING:
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM summary ORDER BY twins ASC' at line 1
    "...men are that they might have joy."
    Nephi

  5. #15
    Join Date
    May 2004
    Posts
    530
    Rep Power
    0

    Default

    Removed the "," from the query before FROM and now this is what i am getting:
    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/www//wcc/score.php on line 15
    "...men are that they might have joy."
    Nephi

  6. #16
    Join Date
    Oct 2005
    Posts
    745
    Rep Power
    0

    Default

    could you post the select statement you're using
    3.14159265358979323846264338327950288
    4197169399375105820974944592307816406
    28620899862803482534211706798 pi 101

  7. #17
    Join Date
    May 2004
    Posts
    530
    Rep Power
    0

    Default

    Yes i did that already :$query = "SELECT side, CONCAT(twins, ' ', tloses) AS stats FROM summary ORDER BY twins ASC";

    but i am getting the error:
    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/www//wcc/score.php on line 15:


    <?php

    include_once("conn.php");

    $f = ($_GET["f"]);
    $query = "SELECT side, CONCAT(twins, ' ', tloses) AS stats FROM summary ORDER BY twins ASC";
    $result = mysql_query($query) or die(mysql_error());
    $numR = mysql_num_rows($result);
    if ($numR = 1) {
    echo"success=1";
    $statsarray = array();
    $sidearray = array();
    $x = 0; // array index
    //collect returned results in associtive manner
    while($result = mysql_fetch_assoc($result)){ //this is line 15
    $statsarray[$x] = $result['stats'];
    $sidearray[$x] = $result['side'];
    $x++;
    }
    //to display

    $loopcontrol = count($side);

    for($a = 0; $a<$loopcontrol; $a++){
    echo $sidearray[$a] . " " . $statsarray[$a];
    }
    }
    else
    {
    echo( "success=0" );
    }

    // Clean up
    mysql_close($dblink);

    ?>
    "...men are that they might have joy."
    Nephi

  8. #18
    Join Date
    Oct 2005
    Posts
    745
    Rep Power
    0

    Default

    Didn't you see this post

    Quote Originally Posted by CGPGroup View Post
    change the query to
    Code:
    $query = "SELECT side, twins + ' ' + tloses AS stats FROM summary ORDER BY twins ASC";
    3.14159265358979323846264338327950288
    4197169399375105820974944592307816406
    28620899862803482534211706798 pi 101

  9. #19
    Join Date
    May 2004
    Posts
    530
    Rep Power
    0

    Default

    $query = "SELECT side, CONCAT(twins,' ', tloses) AS stats FROM summary ORDER BY twins ASC"; the above code is what i have. but i am still getting error.
    "...men are that they might have joy."
    Nephi

  10. #20
    Join Date
    May 2004
    Posts
    530
    Rep Power
    0

    Default

    $query = "SELECT side, CONCAT(twins,' ', tloses) AS stats FROM summary ORDER BY twins ASC"; this is what i have and i am still getting error.

    this is the error:

    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/www//wcc/score.php on line 15

    this is line 15:
    while($result = mysql_fetch_assoc($result)){
    "...men are that they might have joy."
    Nephi

Posting Permissions

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