Home | Help Forums | Web Design Tutorials | Free Swishmax Downloads | All Downloads

 

 

Company

Home

Nework Details

Tutorials

SWiSH 2

SWiSHMax

Flash MX

PHP & MySQL

HTML / JScript

Adobe Photoshop

Corel Draw

Gimp

Miscellaneous

Downloads

Templates

Plugins

Fonts

Wallpapers

Free Images

Scripts and Codes

Products

E-Books

SWiSH BB

SWiSH Templates

SWiSH-DB Newsletter
Subscribe to our newsletter : GO
  Partners / Affiliates

   Swish Templates
   SWiSH Climax
   GimpTalk
   Idea Designs
   Sposatoettore
   Try Acai Berry Diet
   Download Free Ringtones
   Swishzone

Manage your site with Flax Article Content Management System
Understanding conditional block
Category : SWiSHMax | Level : Intermediate | Language : English
Ask Question | Read Comments | Post tutorial | Previous | Next

Web www.swish-db.com

Assuming you know how to use variable
see Tutorial

<?php
$myVar = "test";
$myVar2 = 15;

if ($myVar == "test") {

if ($myVar2 > 10) {
print( "myVar equals test and myVar2 is greater than 10");
}
}

else {
print ("myVar doesn't equal test and i don't know anything about myVar2");
?>



if (condition) {
// code if condition is true
}
else {
// code if condition is false
}



don't forget { } as they delimit the block concerned by any of the two branch. the else part is optionnal and you can ommit it as i do in the second if.

condition can compare anything you want as long it is logic. the operator are
equal: ==
greater: >
greater or equal: >=
lower: <
lower or equal <=
you can use word "or" and "and" if you want to make more complex condition as:
($myVar == "test") or ($myVar2 > 15)

if you think it could be better tell me, it's the really first time i make a tutorial and i think i could be too technical.

regards,
sébastien


All rights reserved - swish-db.com