Jump to content

[SOLVED] How to perform two condition in one else if statement.


y2yang

Recommended Posts

I would like to perform two condition in one else if statement.

 

Here is my code:

 

<?php
} // end if
elseif($Article == "1" && $numrows == 0){
?>

 

Don't know if this is right, but certainly it's not showing what I wanted.

 

BTW, what is &, &&, % used mainly for in php?

 

 

...and by any chance would someone explain what this code do for me? Thanks.

Been having it for a while but still don't know how it works; I don't feel so proud of myself  ???

<?php
if (!empty($count) && $count % $half_point == 0) {
?>

 

I don't know if the first code snippet is right either. What's considered right? It should run without errors.

 

& = a bitwise AND operator (you probably shouldn't worry about this one)

&& = AND operator

% = modulo (which means remainder after division)

 

The second code snippet says "if $count is not empty and the remainder of count divided by half_point is 0, then..."

 

5 % 2 = 1 because 5/2 = 2 with a remainder of 1.

Hey,

 

Can I see the rest of your script so I can see where things may be going wrong before the IF condition, for example you may need to use === instead of == depending on the situation.

 

Either way I will probably have to see more to see how the $Article and $numrows variables are being set.

 

Thanks,

Justin

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.