RSS Forums RSS
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1216 | Replies: 2
Reply
Join Date: Jul 2005
Posts: 2
Reputation: Mike D is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Mike D Mike D is offline Offline
Newbie Poster

Problem with displaying data..

  #1  
Jul 14th, 2005
Howdy folks! I'm having a bit of a dilema with a small piece of my coding. I'm working with a database that stores tour/gig dates for a band. The table has fields that include year, month, day, date, venue_name, name_ext, address, and a couple others.

The field "venue_name" is the name of the club, venue, stadium, etc. The field "name_ext" is a sort of name extention where I can enter in additional information about the location. For instance, if they venue was "Jazz Festival", the name_ext field might be populated with "Stage 12". Now, when I fetch the data using arrays, all of the information is returned correctly. That is, if the name_ext field is populated.

The name_ext field is actually not populated very often, so when that field is blank, and I use the array to fetch all of the data in the record, the html/php code displays a big blank line where the name_ext field would be. So my question is, what would be the best way to go about coding the php/html so that if the name_ext is not populated, it will not display that field at all and just skip to the next field to display?

For instance, if the record had the name_ext field populated, the data returned would like something like this:

Jazz Festival
Stage 12
123 Anystreet
Yourcity, CA
4:00PM - 6:00PM


And, say, that the name_ext field ("Stage 12" in this case) were left blank when the data were entered into the database, it would display the record as such:

Jazz Festival
 
123 Anystreet
Yourcity, CA
4:00PM - 6:00PM


I'm trying to get it to display as:

Jazz Festival
123 Anystreet
Yourcity, CA
4:00PM - 6:00PM



Any pointers, tips, recommended sites? I'm just getting back into scripting after a long break, so forgive me if this is rather layman.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2005
Location: Auckland, New Zealand
Posts: 136
Reputation: sarahk is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
sarahk's Avatar
sarahk sarahk is offline Offline
Junior Poster

Re: Problem with displaying data..

  #2  
Jul 14th, 2005
try something like

echo "<b>{$row['venue_name']}</b><br />";
if (!empty($row['name_ext'])) echo $row['name_ext'].'<br />';

and so on, using the empty() test everytime you have a field that may not have data.

You may also need strip slashes, and I've made assumptions about how your data is returned, etc. I'm sure you can get what I'm suggesting.

Sarah
Reply With Quote  
Join Date: Jul 2005
Posts: 2
Reputation: Mike D is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Mike D Mike D is offline Offline
Newbie Poster

Re: Problem with displaying data..

  #3  
Jul 14th, 2005
Thanks, Sarah. I'll try it see how it works.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 12:08 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC