Forum Moderators: coopster

Message Too Old, No Replies

Else if Structure

         

kevape

7:42 pm on Jan 11, 2008 (gmt 0)

10+ Year Member



i basically wanna say
IF THE FIELDS ARE EMPTY?
if ($image == "" ¦¦ $download == "") {

SET THEM TO NO DATA EXSISTS
$image = "No Data Exsists";
$download = "No Data Exsists";

} else {

PRINT THEM AS THEY ARE?
CAN SOMEBODY HELP ME WITH THE SYNTAX PLEASE

mooger35

8:17 pm on Jan 11, 2008 (gmt 0)

10+ Year Member



if ($image == "" ¦¦ $download == "") {

this is asking if EITHER $image = "" OR $download = ""

So, if one of them is "" then the condition will be true and then it will set both like this:

$image = "No Data Exsists";
$download = "No Data Exsists";

Maybe you should use && (and) instead of ¦¦ (or) because I'm sure you don't want $image to equal "No Data Exists" when there is data.

Another way would be to use 2 if's

assuming you that $image and $download have been set:

if ($image == ""){
$image = "No Data Exists";
} else {
// do stuff
}
if ($download == ""){
$download = "No Data Exsists";
} else {
// do stuff
}

PHP_Chimp

8:39 pm on Jan 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Or -

if ([url=http://uk.php.net/manual/en/function.empty.php]empty[/url]($image)) {
//