Jump to content
Server Maintenance This Week. ×

if Statements


This topic is 6995 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Can any one explain the syntax for the use of "if" and "else" with php. An example would be to show on a php page a check box and text if a field in the database is no and show no check box and text if the field in the database is yes.

An example in my database is a client who receives prints with their new order (send_print field = yes) and another client who does not receive prints with a new order (sent_print field = no). For the client who does not automatically receive prints I would like the php to show a check box and some text. For the client who automatically receive prints I would like nothing to show on the php page.

Thanks in advance for your help - Sam

Link to comment
Share on other sites

Howdy! I haven't tried FX.php yet, which I assume you're using, but here's kinda of what it would be like depending upon specifically what conditions you wanted to check (as stated, you probably need an IF... ELSE IF... but you can probably get away with just an IF... if the default is not to show anything if it's "yes", null, or other value.


<?

if ($send_print == "no")

{ 

print ("<input type='checkbox' name='mycheckboxname' value='yes'>some text");

}

?>





If you ever need to check the same variable for various values, a switch/case statement is good...





<? 

switch($send_print)

{

case "no":

print ("<input type='checkbox' name='mycheckboxname' value='yes'>some text");

break;



case "yes":

break;



default:

print ("This field should have either been YES or NO only.");

}

Hope this helps some...

--ST

Link to comment
Share on other sites

This topic is 6995 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.