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) {
?>

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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