Jump to content

Recommended Posts

hey guys,

I have a page that displays events that are stored in the db but sometimes some of the fields are empty and when that happens I don't want it to display that line.

this is what I mean

[code]
$events_allrow = mysql_fetch_array($display_result);
echo '<div style="margin-left:10px; margin-top:10px "><img src="images/square1.jpg" align="absmiddle" style="margin-right:5px "><strong class="light_gray">'.$events_allrow['name'].'</strong></div>
<div style="margin-left:9px; margin-top:7px; width:354px "><div style="position:relative; left:0; top:0; "><img src="../img/events/'.$events_allrow['name'].'/thumbnails/'.$events_allrow['flyer1'].'" align="left" style="margin-right:13px "></div>
<div>Where: <strong>'.$events_allrow['club'].'<br /></strong>
When: <strong>'.$events_allrow['date'].'<br /></strong></div>
Time: <strong>'.$events_allrow['time'].'<br /></strong></div>
Performers: <strong>'.$events_allrow['performers'].'<br /></strong></div>
DJ: <strong>'.$events_allrow['dj'].'<br /></strong></div>
Promoter: <strong>'.$events_allrow['promoter'].'<br /></strong></div>
Music: <strong>'.$events_allrow['music'].'<br /></strong></div>
Cover Price: <strong>$'.$events_allrow['cover'].'<br /></strong></div>
Dress code: <strong>'.$events_allrow['dress'].'<br /></strong></div>
Notes: <strong>'.$events_allrow['notes'].'<br /></strong></div>
Tickets: <strong>'.$events_allrow['tickets'].'<br /></strong></div>
Guestlist: <strong>'.$events_allrow['guestlist'].'</strong></div>
<div style="margin-top:7px " align="right"></div>
</div>
<div style="margin-top:7px " align="right"><a href="index.php?a=events&id=all" class="light_gray" style="text-decoration:none "><strong>view all</strong></a></div>
</div>

<div style="margin-left:8px; margin-top:10px; margin-right:8px; height:1px; background-image:url(images/dot.jpg) "><img src="images/spacer.gif"></div>';
[/code]

so for a specific event the 'performersr' field is empty what would be the easiest way to not make it display Performers:

and that applies to most of the fields
Link to comment
https://forums.phpfreaks.com/topic/14621-not-to-display-empty-fields/
Share on other sites

thanks guys but I already knew that, was just hoping that there was a cleaner way to do this.

[code]
$events_allrow = mysql_fetch_array($display_result);
echo '<div style="margin-left:10px; margin-top:10px "><img src="images/square1.jpg" align="absmiddle" style="margin-right:5px "><strong class="light_gray">'.$events_allrow['name'].'</strong></div>
<div style="margin-left:9px; margin-top:7px; width:354px "><div style="position:relative; left:0; top:0; "><img src="../img/events/'.$events_allrow['name'].'/thumbnails/'.$events_allrow['flyer1'].'" align="left" style="margin-right:13px "></div>
<div>Where: <strong>'.$events_allrow['club'].'<br /></strong>
When: <strong>'.$events_allrow['date'].'<br /></strong></div>
Time: <strong>'.$events_allrow['time'].'<br /></strong></div>';
if ($events_allrow['performers'] != '') {
    echo 'Performers: <strong>'.$events_allrow['performers'].'<br /></strong></div>';
}
if ($events_allrow['djs'] != '') {
  echo 'DJ: <strong>'.$events_allrow['dj'].'<br /></strong></div>';
}
if ($events_allrow['promoter'] != '') {
    echo 'Promoter: <strong>'.$events_allrow['promoter'].'<br /></strong></div>';
}
if ($events_allrow['music'] != '') {
    echo 'Music: <strong>'.$events_allrow['music'].'<br /></strong></div>';
}
if ($events_allrow['cover'] != '') {
    echo 'Cover Price: <strong>$'.$events_allrow['cover'].'<br /></strong></div>';
}
if ($events_allrow['dress'] != '') {
    echo 'Dress code: <strong>'.$events_allrow['dress'].'<br /></strong></div>';
}
if ($events_allrow['notes'] != '') {
    echo 'Notes: <strong>'.$events_allrow['notes'].'<br /></strong></div>';
}
if ($events_allrow['tickets'] != '') {
    echo 'Tickets: <strong>'.$events_allrow['tickets'].'<br /></strong></div>';
}
if ($events_allrow['guestlist'] != '') {
    echo 'Guestlist: <strong>'.$events_allrow['guestlist'].'</strong></div>';
}
echo '<div style="margin-top:7px " align="right"></div>
</div>
<div style="margin-top:7px " align="right"><a href="index.php?a=events&id=all" class="light_gray" style="text-decoration:none "><strong>view all</strong></a></div>
</div>

<div style="margin-left:8px; margin-top:10px; margin-right:8px; height:1px; background-image:url(images/dot.jpg) "><img src="images/spacer.gif"></div>';
[/code]

btw for those lines to work it has to be != '' and not !=0
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.