944,150 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1782
  • PHP RSS
Jul 14th, 2005
0

Problem with displaying data..

Expand Post »
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:

PHP Syntax (Toggle Plain Text)
  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:

PHP Syntax (Toggle Plain Text)
  1. Jazz Festival
  2.  
  3. 123 Anystreet
  4. Yourcity, CA
  5. 4:00PM - 6:00PM

I'm trying to get it to display as:

PHP Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Mike D is offline Offline
2 posts
since Jul 2005
Jul 14th, 2005
0

Re: Problem with displaying data..

try something like

PHP Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 1
Junior Poster
sarahk is offline Offline
138 posts
since Apr 2005
Jul 14th, 2005
0

Re: Problem with displaying data..

Thanks, Sarah. I'll try it see how it works.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Mike D is offline Offline
2 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Html+PHP Forms
Next Thread in PHP Forum Timeline: Php code confusion. Not sure how to describe





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC