SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy how do I filter ranked results from mysql table?

    I have the following code working perfectly well to rank my students in different classes by highest mark, but when I want to filter by year it's returning Column 'year' in where clause is ambiguous. Help!!!

    PHP Code:
    <?php

    $currentPage 
    $_SERVER["PHP_SELF"];

    $colname_Recordset2 "-1";
    if (isset(
    $_GET['recordID'])) {
      
    $colname_Recordset2 = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);
    }
    mysql_select_db($database_arundel$arundel);
    $query_Recordset2 sprintf("SELECT v1.s_surname, v1.mark, v1.s_name, v1.year, v1.class, COUNT(v2.mark) AS Rank   
    FROM biology v1 
    JOIN biology v2 ON v1.mark < v2.mark OR (v1.mark=v2.mark and v1.s_surname = v2.s_surname)
    WHERE `year` = '%s'
    GROUP BY v1.s_surname, v1.mark 
    ORDER BY  v1.mark DESC"
    $colname_Recordset2);
    $Recordset2 mysql_query($query_Recordset2$arundel) or die(mysql_error());
    $row_Recordset2 mysql_fetch_assoc($Recordset2);
    $totalRows_Recordset2 mysql_num_rows($Recordset2);

    ?>
    Last edited by SpacePhoenix; Feb 27, 2011 at 19:35. Reason: put php tags round php code to improve readability


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
  •