echo statements to leave no blank lines

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jarow
Forum Commoner
Posts: 83
Joined: Tue Jan 28, 2003 2:58 am

echo statements to leave no blank lines

Post by jarow »

Am very new to php. I have the following php echo statements:
<p><?php echo $row_cv['institucion']; ?></p>
<p><?php echo $row_cv['department']; ?></p>
<p><?php echo $row_cv['department2']; ?></p>
<p><?php echo $row_cv['address']; ?></p>
<p><?php echo $row_cv['city']; ?>, <?php echo $row_cv['country']; ?>.&nbsp; <?php echo $row_cv['postalcode']; ?></p>

How can a write a statement that in the case that there is no department or department2 that it wouldn't leave a blank line, that everything would move "up", so to speak.

Thanks for your help.
User avatar
andre_c
Forum Contributor
Posts: 412
Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah

Post by andre_c »

do this for each one:

Code: Select all

<?
if ($row_cv['institution']!='') echo "<p>$row_cv[institution]</p>\n";
?>
jarow
Forum Commoner
Posts: 83
Joined: Tue Jan 28, 2003 2:58 am

Post by jarow »

thanks, that works...but how can I get the following to appear on the same line:

if ($row_cv['city']!='') echo "<p>$row_cv[city].</p>";
if ($row_cv['country']!='') echo "<p>&nbsp;$row_cv[country]&nbsp;</p>";
if ($row_cv['postalcode']!='') echo "<p>$row_cv[postalcode]</p>";
Post Reply