Problem with displaying data..

Reply

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

Problem with displaying data..

 
0
  #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:

  1. Jazz Festival
  2. Stage 12
  3. 123 Anystreet
  4. Yourcity, CA
  5. 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:

  1. Jazz Festival
  2.  
  3. 123 Anystreet
  4. Yourcity, CA
  5. 4:00PM - 6:00PM

I'm trying to get it to display as:

  1. Jazz Festival
  2. 123 Anystreet
  3. Yourcity, CA
  4. 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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 138
Reputation: sarahk is an unknown quantity at this point 
Solved Threads: 1
sarahk's Avatar
sarahk sarahk is offline Offline
Junior Poster

Re: Problem with displaying data..

 
0
  #2
Jul 14th, 2005
try something like

  1. echo "<b>{$row['venue_name']}</b><br />";
  2. 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 Quick reply to this message  
Join Date: Jul 2005
Posts: 2
Reputation: Mike D is an unknown quantity at this point 
Solved Threads: 0
Mike D Mike D is offline Offline
Newbie Poster

Re: Problem with displaying data..

 
0
  #3
Jul 14th, 2005
Thanks, Sarah. I'll try it see how it works.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC