| | |
Problem with displaying data..
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2005
Posts: 2
Reputation:
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:
PHP Syntax (Toggle Plain Text)
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:
PHP Syntax (Toggle Plain Text)
Jazz Festival 123 Anystreet Yourcity, CA 4:00PM - 6:00PM
I'm trying to get it to display as:
PHP Syntax (Toggle Plain Text)
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.
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
PHP Syntax (Toggle Plain Text)
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
![]() |
Similar Threads
- Winsock C++ help: receiving data (C++)
- Cartesian Product Problem (Oracle)
- displaying data onto a web page (ASP.NET)
- Problem with CRT monitor Data Cable (Monitors, Displays and Video Cards)
- suggestion on data stuctures to use (C)
- Want to Route data Between 2 LAN (Networking Hardware Configuration)
- Displaying Data in C programmming (C)
Other Threads in the PHP Forum
- Previous Thread: Html+PHP Forms
- Next Thread: Php code confusion. Not sure how to describe
| Thread Tools | Search this Thread |
action address ajax apache api array auto autoincrement beginner binary broken cakephp checkbox class classes cms code cron curl database date dehasher destroy display domain dynamic echo email error errorlog file files folder form format forms function functions google href htaccess html image include insert interactive ip java javascript joomla limit link load login mail malfunctioning masterthesis menu mlm multiple mysql nodes oop paypal pdf php popup problem query radio ram random record recursion reference remote return script search server sessions sms source space sql syntax system table tutorial unset update upload url validation validator variable video web websitecontactform youtube





