Re: Avoiding blank lines in HTML when field is empty

From: Date: Fri, 24 Oct 2003 14:25:58 +0000
Subject: Re: Avoiding blank lines in HTML when field is empty
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-167430@lists.php.net to get a copy of this message
On Thu, 23 Oct 2003 12:46:29 -0500, Robb Kerr wrote: Thanx for all the help. Your suggestions worked beautifully. Robb > I'm a PhP /MySQL newbie so please excuse the simple question. I'm returning > results from a MySQL query on a webpage. My code includes... > > <td valign="top"> > <?php echo $row_rsVandyDivAddresses['First_Name']; ?> <?php echo > $row_rsVandyDivAddresses['Last_Name'];?>, <?php echo > $row_rsVandyDivAddresses['Degree']; ?> > <br> > <?php echo $row_rsVandyDivAddresses['Address']; ?> > <br> > <?php echo $row_rsVandyDivAddresses['City']; ?>, <?php echo > $row_rsVandyDivAddresses['State']; ?><?php echo > $row_rsVandyDivAddresses['Zip']; ?> > <br> > Phone: <?php echo $row_rsVandyDivAddresses['Phone']; ?> > <br> > Email: <?php echo $row_rsVandyDivAddresses['Email']; ?> > </td> > > Here's the problem. Some of the fields are empty (for instance 'Address') > and the way my code is configured a blank line appears in the returned data > when the field is empty. How do I change this code to add a conditional that > only echos the field contents AND the <br> when the field is NOT empty? > > I've tried... > > <?php if (!empty($row_rsVandyDivAddresses['Address']) echo > $row_rsVandyDivAddresses['Address']); ?> > > but don't know how to include the line break <br> in the if statement. > > Any help is greatly appreciated, > Robb

« previous php.general (#167430) next »