Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1216 | Replies: 2
![]() |
•
•
Join Date: Jul 2005
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
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:
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:
I'm trying to get it to display as:
Any pointers, tips, recommended sites? I'm just getting back into scripting after a long break, so forgive me if this is rather layman.
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.
•
•
Join Date: Apr 2005
Location: Auckland, New Zealand
Posts: 136
Reputation:
Rep Power: 4
Solved Threads: 1
try something like
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
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
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)





Linear Mode