close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Multiple Conditions in If Clause Question

Thread began 1/02/2019 7:52 am by astrostrom | Last modified 5/12/2020 10:53 am by Ray Borduin | 693 views | 3 replies |

astrostrom

Multiple Conditions in If Clause Question

Is it possible to have several options in an if clause?

If possible, I would like to combine these two conditions into one statement so that I would get either result A or B and, if neither condition was met, then get the (else) default condition would be returned.

Condition 1:

<?php
if ($rsAgenda->getColumnVal("address_type") == "A")
{include("agenda_menu_2.php");
}
else
include("agenda_menu.php");
}
?>

Condition 2:

<?php
if ($rsAgenda->getColumnVal("address_type") == "B")
{include("agenda_menu_3.php");
}
else {
include("agenda_menu.php");
}
?>

Sign in to reply to this post

Ray BorduinWebAssist

php:
<?php

if ($rsAgenda->getColumnVal("address_type") == "A") {
  include(
"agenda_menu_2.php");
} else if (
$rsAgenda->getColumnVal("address_type") == "B") {
  include(
"agenda_menu_3.php");
} else {
  include(
"agenda_menu.php");
}
?>
Sign in to reply to this post
Did this help? Tips are appreciated...

astrostrom

That works!


Many thanks again for your help.

Sign in to reply to this post

astrostrom

I have a new if/else challenge.

I have a situation where I have a video file and and image file in the database. All records have an image file but only some have a video file.
I also have a 'show_vid' field.

When this is set to "Y", I only want to only show the video file, otherwise when it is checked "N" it should show the image instead.

This works when there is not a video, but when there is a video, and 'set_id' is set to "Y", I get BOTH the video file and the image file.

Obviously, I am missing something in my syntax below:
---------------------------

<?php
if ($rsObservation->getColumnVal('show_vid') == "Y")
{echo $rsObservation->getColumnVal("video",false);
}
else
{echo'<img src="upload/news/';
echo $rsObservation->getColumnVal("image",false);
echo '" width="1920" height="1080" alt=""/>';
}
?>
----------------------

UPDATE: Actually this now seems to work like this using two PHP statements:

---------------------------

<?php
if ($rsObservation->getColumnVal('show_vid') == "Y")
{echo $rsObservation->getColumnVal("video",false);
}
else {
echo "";}

?>

<?php
if ($rsObservation->getColumnVal('show_vid') == "N")
{echo'<img src="upload/news/';
echo $rsObservation->getColumnVal("image",false);
echo '" alt=""/>';
}
else {
echo "";}

?>
----------------------------------------------------

Thanks for any advice.

Sign in to reply to this post

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