Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP Help? Displaying Results

    Alright I am displaying information from an excel spreadsheet from a database through MySQL, someone else set it up for me with the code. They put it to where it only displays 11 names of the 500+ on the spreadsheet, I need to know how I can display all of the names not just 11 of them... heres the code:

    Code:
    <?php
               $designation = ($_GET['designation']);
               $year = ($_GET['year']);
               echo $designation;
               echo "&nbsp;";
               echo $year;  
       
               if ($designation == 1) {// had to make sure to use == instead of = here
        $query = "SELECT * FROM members WHERE designation = $designation AND iYear = $year ORDER BY fullName ASC LIMIT 0, 600";
         
      
       
        } else if ($designation == 0 ) {// had to make sure to use == instead of = here
         
        $query = "SELECT * FROM members WHERE designation = $designation AND hYear = $year ORDER BY fullName ASC LIMIT 0, 600";
         
       
        }
        $result = @mysql_query($query);
        if ($result) {
            echo '<table align=\"left\" cellspacing=\"0\" cellpadding=\"5\" border=\"1\">';
            while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
                echo "<tr><td align=\"left\" valign=\"top\"><a href=\"member_detail.php?ID=$row[0]\">►&nbsp;$row[1]&nbsp; $row[3]</a>";
                echo "</td></tr>\n";
           
            } echo '</table>';
        }
        ?>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,462
    Thanks
    76
    Thanked 4,373 Times in 4,338 Posts
    The SQL query is only getting records that match the WHERE clause.
    Code:
    SELECT * FROM members 
    WHERE designation = $designation AND hYear = $year 
    ORDER BY fullName ASC 
    LIMIT 0, 600
    That is, only those records that match the given $designation (a value from PHP) and $year (ditto).

    In addition, the LIMIT will only give you the first 600 matches.

    If you don't want the "filters" on $designation and $year, remove the WHERE clause.

    If you don't want to limit it to 600 records, remove the LIMIT clause.
    Code:
    SELECT * FROM members 
    ORDER BY fullName ASC
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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