The proper way to do it?
Posted: Wed Jan 03, 2007 7:55 pm
Ok what I want to do is return results from the db based on what options the user selects from a form.
I was using
But am thinking there must be a better way to do it? The problem that I am having is the SELECT statment and the use of foreach since it will display all results in the $query
...
This is one of the ideas I had untill I relised this problem, I know it does not work, the if statments do work ok and they are the form options.
I was using
Code: Select all
foreach ($line as $col_value) This is one of the ideas I had untill I relised this problem, I know it does not work, the if statments do work ok and they are the form options.
Code: Select all
$query = "SELECT pn_name, pn_uname, pn_phone, pn_duesexdate, barc_id FROM _users WHERE pn_duesexdate > 100 ORDER BY 'pn_name' ASC";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
// output table
echo '<table width="100%" border="0" cellspacing="0" cellpadding="3">';
// Set the headings
echo '<tr><td><b>Member Name</b></td>'
if ($call== '1') echo '<td><strong>Call</strong></td>';
if ($phone== '1') echo '<td><strong>Phone</strong></td>';
if ($cell== '1') echo '<td><strong>Cell</strong></td></tr>';
if ($fax== '1') echo '<td><strong>Fax</strong></td></tr>';
if ($address== '1') echo '<td><strong>Address</strong></td></tr>';
if ($address== '1') echo '<td><strong>City</strong></td></tr>';
if ($address== '1') echo '<td><strong>State</strong></td></tr>';
if ($address== '1') echo '<td><strong>Zip</strong></td></tr>';
if ($ex_date== '1') echo '<td><strong>Ex. Date</strong></td></tr>';
if ($type== '1') echo '<td><strong>Mem. Type</strong></td></tr>';
if ($id== '1') echo '<td><strong>Mem. ID</strong></td>';
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "<tr>";
foreach ($line as $col_value) {
echo '<td><div align="center">' . $col_value .'</div></td>';
}
echo '<td>
</td>';
echo "</tr>";
}
echo "</table>";