close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

PHP hide field if empty

Thread began 1/05/2011 1:51 pm by ruth265305 | Last modified 6/05/2013 10:46 am by charles164095 | 10061 views | 16 replies |

ruth265305

PHP hide field if empty

I have a recordset with several fields that display in a table.... If a field is empty (no data); I'd like to hide that table row so a blank area doesn't appear.

I see a hide/show recordset if empty, but no way to assign it to just a field is empty.

Sign in to reply to this post

Jason ByrnesWebAssist

you would need to hand code an if statement around the code for the row.


for example, the code for the row may loo like;

php:
<tr>
<th>A Label:</th>
<td><?php echo($row_recordsetName['columnName']); ?></td>
</tr>




you could add an if statement around that to only show if the column is not blank:

php:
<?php if($row_recordsetName['columnName'] != "") { ?>
<tr>
<th>A Label:</th>
<td><?php echo($row_recordsetName['columnName']); ?></td>
</tr>
<?php ?>
Sign in to reply to this post

ruth265305

almost there

Hi Jason:

Thanks for your help.

I get this error:
Parse error: syntax error, unexpected ')', expecting ',' or ';' in /hsphere/local/home/xcski/xcski.org/member_ads.php on line 143 {{{143 is the <td align="left" code }}}

Here's my code:

<?php if($row_rsEquipment['price'] != "") { ?>
<tr>
<td align="left" valign="top" bgcolor="#FBFCFD" ><?php echo($row_rsEquipment['price'])); ?> USD</td>
</tr>
<?php } ?>

Sign in to reply to this post

Jason ByrnesWebAssist

you have an extra parenthesis:

php:
<td align="left" valign="top" bgcolor="#FBFCFD" ><?php echo($row_rsEquipment['price'])); ?> USD</td>



should be:

php:
<td align="left" valign="top" bgcolor="#FBFCFD" ><?php echo($row_rsEquipment['price']); ?> USD</td>
Sign in to reply to this post

ruth265305

My mistake!

Hi Jason:
Thank you ... I had an extra parenthesis in there. It worked perfectly and thanks once again for you quick response and help. Always appreciate it!

Sign in to reply to this post

Jason ByrnesWebAssist

No worries, glad to hear it's working.

Sign in to reply to this post

wbrooks199805

Question

Hi Jason,

If I am using data assist details page, If I want to do this to all my fields, should I delete the "show if no record found" at the bottom of the page..I am asking because I kept getting a syntax error when trying to do it on all the fields.

Thx in advance!

Sign in to reply to this post

Jason ByrnesWebAssist

no, you dont need to delete the show if no records are found section.


if your getting a syntax error, include the full error and a copy of your page and I will look into the cause of it.

Sign in to reply to this post

wbrooks199805

Thanks!

I got it..I think I needed to put the data in tables.

Sign in to reply to this post

Jason ByrnesWebAssist

ok, glad to hear it is working.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...