close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

PHP code to prevent empty database field from displaying

Thread began 2/14/2016 6:33 pm by John | Last modified 2/15/2016 12:12 pm by John | 1726 views | 9 replies

John

PHP code to prevent empty database field from displaying

I have just upgraded to DW CC2015 and purchased the entire WebAssist Suite. I have always used some PHP code to make it so an empty database field will not display on the web page. Very simple and always worked. Now, for some reason it no longer works and it's a critical thing for the websites I develop. Here is the code (recordset and field names changed to protect the innocent):

<?php if($row_rsRecordset['db_field']<>"") { ?><a href="<?php echo($row_rsRecordset->getColumnVal("db_field")); ?>" target="_blank">Website</a><?php } ?>

I have also tried !="" instead of <>"" and <? }?> at the end instead of <?php } ?> and still didn't work.

This is basically a text link to display a link to an author's website. If the field is empty (no URL in the field), the text should not display. The problem is that it never displays. I have the same thing for Facebook and Twitter for the author, and the same thing happens - nothing displays. I have probably 20 websites where I use this same code and it works fine, mostly implemented in Dreamweaver CS6 or earlier. Any idea what this is not working now. I have spent hours today trying to figure it out with no success. The MySQL database is the same, and I have checked the data and the fields, everything is as it should be but it doesn't work. Very frustrated!!

I have also tried it where some authors have a photo and some don't, so I want to hide it when they don't. Same problem. When I wrap the code around the image, none of them show up.

Thanks,
John Burke

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...