white space from empty datafields when echo-ing?
Posted: Sun Jul 13, 2003 7:06 am
Not that I can right a snippet of code (yet) but am great at copy & paste!!
............
My first project with PHP & MySQL is a health resources directory; currently am able to display database contents very nicely except I get lots of white space when fields are empty. For example, some resource facilities have one address, others 2, one place has 4, some have 1 or 2 phone numbers, etc. I am just echoing everything, blank or not!
Looks like crap really....I probably need some kind of IF thingie going on?
I have 40 separate pages of resource types (housing, food, financial, etc etc) and use INCLUDE in each so i now only have to modify one itty bitty page of php, and would appreciate any suggestions (esp. those that involve copy&paste! ........kidding!!!!)
here it is:
<?php
// Display
while ( $row = mysql_fetch_array($result) ) {
echo("<font size=+'1'><b>" . $row["name"] . "</b></font><hr color='blue'>");
echo($row["description1"] . "<p>");
echo($row["description2"] . "");
echo("<table><tr><td align='left' valign='top'>" . $row["address1"] . "");
echo("<br>" . $row["city1"] . "");
echo("<br>" . $row["state1"] . "");
echo("<br>" . $row["zip1"] . "</td>");
echo("<td align='left' valign='top'>" . $row["address2"] . "");
echo("<br>" . $row["city2"] . "");
echo("<br>" . $row["state2"] . "");
echo("<br>" . $row["zip2"] . "</td></tr>");
echo("<tr><td align='left' valign='top'>" . $row["address3"] . "");
echo("<br>" . $row["city3"] . "");
echo("<br>" . $row["state3"] . "");
echo("<br>" . $row["zip3"] . "</td>");
echo("<td align='left' valign='top'>" . $row["address4"] . "");
echo("<br>" . $row["city4"] . "");
echo("<br>" . $row["state4"] . "");
echo("<br>" . $row["zip4"] . "</td></tr></table>");
echo("<br>phone1: " . $row["phone1"] . "");
echo("<br>phone2: " . $row["phone2"] . "");
echo("<br>TDD/TTY: " . $row["tdd"] . "");
echo("<br>fax: " . $row["fax"] . "<p>");
echo($row["times"] . "");
echo("<br>Payments Accepted: " . $row["payments"] . "<p><hr><a href='../resources.html'><i>Back to Resource Directory</i></a><p>");
}
?>
This is displayed at http://www.pwa.org Support -> Resources -> pick a category
Thanks in advance for taking a noob by the hand!
............
My first project with PHP & MySQL is a health resources directory; currently am able to display database contents very nicely except I get lots of white space when fields are empty. For example, some resource facilities have one address, others 2, one place has 4, some have 1 or 2 phone numbers, etc. I am just echoing everything, blank or not!
Looks like crap really....I probably need some kind of IF thingie going on?
I have 40 separate pages of resource types (housing, food, financial, etc etc) and use INCLUDE in each so i now only have to modify one itty bitty page of php, and would appreciate any suggestions (esp. those that involve copy&paste! ........kidding!!!!)
here it is:
<?php
// Display
while ( $row = mysql_fetch_array($result) ) {
echo("<font size=+'1'><b>" . $row["name"] . "</b></font><hr color='blue'>");
echo($row["description1"] . "<p>");
echo($row["description2"] . "");
echo("<table><tr><td align='left' valign='top'>" . $row["address1"] . "");
echo("<br>" . $row["city1"] . "");
echo("<br>" . $row["state1"] . "");
echo("<br>" . $row["zip1"] . "</td>");
echo("<td align='left' valign='top'>" . $row["address2"] . "");
echo("<br>" . $row["city2"] . "");
echo("<br>" . $row["state2"] . "");
echo("<br>" . $row["zip2"] . "</td></tr>");
echo("<tr><td align='left' valign='top'>" . $row["address3"] . "");
echo("<br>" . $row["city3"] . "");
echo("<br>" . $row["state3"] . "");
echo("<br>" . $row["zip3"] . "</td>");
echo("<td align='left' valign='top'>" . $row["address4"] . "");
echo("<br>" . $row["city4"] . "");
echo("<br>" . $row["state4"] . "");
echo("<br>" . $row["zip4"] . "</td></tr></table>");
echo("<br>phone1: " . $row["phone1"] . "");
echo("<br>phone2: " . $row["phone2"] . "");
echo("<br>TDD/TTY: " . $row["tdd"] . "");
echo("<br>fax: " . $row["fax"] . "<p>");
echo($row["times"] . "");
echo("<br>Payments Accepted: " . $row["payments"] . "<p><hr><a href='../resources.html'><i>Back to Resource Directory</i></a><p>");
}
?>
This is displayed at http://www.pwa.org Support -> Resources -> pick a category
Thanks in advance for taking a noob by the hand!