Forum Moderators: coopster
The problem I'm having is when a location name is not entered a break occurs and pushes info down one line. If there is no location, I want to info to appear valigned top.
Here an example:
<snip>
and code:
$con = mysql_connect("#*$!xx","#*$!#*$!","#*$!#*$!");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("#*$!#*$!xx", $con);
$result = mysql_query("SELECT * FROM events ORDER BY date ASC");
echo "
<table border='1' cellspacing='0' summary='Event Calendar'id='cal'>
<tr>
<th scope='col' width='60'>Date</th>
<th scope='col' width='110'>Event</th>
<th scope='col' width='75'>Time</th>
<th scope='col' width='175'>Location</th>
<th scope='col' >Other</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td valign='top'>" . $row['date'] . "<br></td>";
echo "<td valign='top'>" . $row['name'] . "</td>";
echo "<td valign='top'>" . $row['begin'] . "-" . $row['end'] . "</td>";
echo "<td valign='top'>" . $row['location'] . "<br>" . $row['address'] . "<br>" . $row['city'] . ", " . $row['state'] . "<br>" . $row['country'] . "" . $row['zip'] . "</td>";
echo "<td>Hosted by:<br>" . $row['host1'] . "<br>" . $row['host1-phone'] . "<br>" . "<br>" . $row['host2'] . "<br>" . $row['host2-phone'] ."</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
PLEASE HELP!
thank you sooo much
[edited by: eelixduppy at 7:32 pm (utc) on Feb. 22, 2008]
[edit reason] no URLs, please [/edit]
echo "<td valign='top'>" . $row['location'] . "<br>" . $row['address'] . "<br>" . $row['city'] . ", " . $row['state'] . "<br>" . $row['country'] . "" . $row['zip'] . "</td>";
if (![url=http://uk2.php.net/manual/en/function.empty.php]empty[/url]($row['location'])) {
echo "<td valign='top'>" . $row['location'] . "<br>" . $row['address'] . "<br>" . $row['city'] . ", " . $row['state'] . "<br>" . $row['country'] . "" . $row['zip'] . "</td>";
}
else {
echo "<td valign='top'>" . $row['address'] . "<br>" . $row['city'] . ", " . $row['state'] . "<br>" . $row['country'] . "" . $row['zip'] . "</td>";
}
You may want to look at both empty [uk2.php.net] and also isset [uk2.php.net] as they are both useful for checking to see if variables are useful.
<edit>
Would help if I used not empty for the if loop...
[edited by: PHP_Chimp at 8:49 pm (utc) on Feb. 22, 2008]