...

View Full Version : PHP Help? Displaying Results



utkdave
09-02-2011, 08:06 PM
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:


<?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>';
}
?>

Old Pedant
09-02-2011, 08:25 PM
The SQL query is only getting records that match the WHERE clause.


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.


SELECT * FROM members
ORDER BY fullName ASC



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum