Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

How to account for empty fields Topic is solved

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
Paul
Posts: 165
Joined: Mon Aug 25, 2025 6:03 am
Has thanked: 31 times
Been thanked: 4 times

How to account for empty fields

Unread post by Paul »

I have my Browse form code that displays records with hyperlinks to files when the Print button is clicked.
(See viewtopic.php?t=12663)

In the Browse form edit screeen, I have this as an example:
Title: Audio 5 URL
Display:

Code: Select all

CONCAT('<a href="', pk_audio_url_5, '" target="_blank" download>Download Audio 5</a>')
If pk_audio_url_5 happens to be blank (nothing was entered in the audio file url field) then I get a url like this in the displayed Print page:

Code: Select all

http://localhost/nubuilder2/core/nurunhtml.php?i=68ebda6957edf1f
which is bad.

Other than deleting the display code entirely (not prefereable), how do I account for empty fields?
Paul
Posts: 165
Joined: Mon Aug 25, 2025 6:03 am
Has thanked: 31 times
Been thanked: 4 times

Re: How to account for empty fields

Unread post by Paul »

ChatGPT answered my question:

Code: Select all

IF(
  pk_audio_url_5 <> '',
  CONCAT('<a href="', pk_audio_url_5, '" target="_blank" download>Download Audio 5</a>'),
  'No audio available'
)
Post Reply