Hi all,
I have a quick question about pulling data from my database. I have pages that show tours based on which departure city is in the 'dayshore_tourdepart' field of the database.
Here's the first query that then displays results in a table for that city:
PHP Code:
<?php require_once('../data/connect.php'); ?>
<?php
$sql_1 = "SELECT * FROM dayshore WHERE dayshore_tourdepart = 'Anchorage' ORDER BY 'id'";
if (!$queryResource = mysql_query($sql_1, $dbconn)) {
trigger_error('Query error' .mysql_error(). 'SQL:' .$sql_1);
}
?>
<table width="97%" align="center" bgcolor="#eeeeee">
<tr bgcolor="#d6d6c6">
<td width="60" height="22"><strong>Tour#</strong></td>
<td> <strong>Anchorage Day Tour</strong></td>
<td> <strong>Duration</strong></td>
<td> <strong>Departure</strong></td>
</tr>
<?php
while ($row = mysql_fetch_array($queryResource, MYSQL_ASSOC)) {
echo "<tr>\n";
echo "<td bgcolor=\"#f8f8f8\" width=\"35\" align=\"left\"><strong>$row[id]</strong></td>";
echo stripslashes("<td bgcolor=\"#f8f8f8\"> <a href=\"$location?page=tourdetails&id=$row[id]\">
$row[dayshore_tourname]</a> </td>");
echo "<td width=\"115\" bgcolor=\"#f8f8f8\"> $row[dayshore_tourduration] </td>";
echo "<td width=\"115\" bgcolor=\"#f8f8f8\"> $row[dayshore_tourdepart] </td>";
echo "</tr>\n";
}
?>
</table>
So....How can I hide the table and it's title cells if there are no tours that exist in the database, that have that city in the specific field??
If I put the
Code:
<table width="97%" align="center" bgcolor="#eeeeee">
<tr bgcolor="#d6d6c6">
<td width="60" height="22"><strong>Tour#</strong></td>
<td> <strong>Anchorage Day Tour</strong></td>
<td> <strong>Duration</strong></td>
<td> <strong>Departure</strong></td>
</tr>
in the 'while' loop, won't it display that <tr> for each row returned??
For an example of how this is broken down, please visit my site.
Any help would be appreciated.
Thanks,
-TC
Bookmarks