Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Show if field is not empty - PHP/MySQL

Explorer ,
Sep 12, 2007 Sep 12, 2007
Is there a way I can only show bits of a page if a recordset has entries in a certain field, automatically hiding the area if the field is empty. (PHP/MySQL)

To put it in real terms, I have loads of products listed in a repeating table. If a product has a photo gallery related to it there is a 1 entered in 'photos' field, it has a video attached here is a 1 entered in 'videos field and likewise for reviews it will have a 1 entered in the reviews field.
What I'd like to have is a photo, video and review icon/link in the 'master table' which only appears in the repeated products that have a 1 listed in that field and have them not appear at all when there is a 0 in the field.

Can anyone help me figure it out
TOPICS
Server side applications
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 12, 2007 Sep 12, 2007
If you don't have ADDT, maybe this free old but very pratical extension:

http://www.brettbrewer.com/component/option,com_vfm/Itemid,41/do,view/file,PHP_SIRFCIT.mxp/

Regards,
Márcio
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 13, 2007 Sep 13, 2007
Thanks Márcio,

If ADDT will do that for me I'll buy it.
Before I get my credit card out can you just confirm that ADDT will allow me to show or hide an area according to a field condition?

Cheers

Dave
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Sep 13, 2007 Sep 13, 2007
ADDT is certainly a great help, as it - among many other features - will allow you define whatever page element as "show/hide" based on a query result -- for this it´s using a so-called "condition builder" which lets you do that without coding.

However you can achieve the same result without needing to resort to ADDT -- by using a basic "if" condition that´s checking the respective table column for having the value "1" stored, and if so, display the page segment

The following 3 examples should work when replacing the sample "queryname" with the query name your page is actually using:

<?php if ($row_queryname['photos'] == '1') {?>
display photo icon here
<?php }?>

<?php if ($row_queryname['videos'] == '1') {?>
display video icon here
<?php }?>

<?php if ($row_queryname['reviews'] == '1') {?>
display videos icon here
<?php }?>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 17, 2007 Sep 17, 2007
LATEST
Thanks guys, I tried both methods and Günter's route worked best. The result is exactly what I was looking for and I feel I have another handy tool in my PHP beginners toolkit as a result.

Thanks again.

Dave
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines