Jump to content

if statement help.


seany123

Recommended Posts

okay so basically what i need to do is have a if statement, but the twist is that the value of House_id could be 0 or anything from 1 to 16... this is basically what im wanting but obviously this code wont work.

 

if ($player->house_id == 2 || $player->house_id == 3 || $player->house_id == 4) {

}

 

But also it would go up to 16 instead of 4.

 

can anyone help me do this?

 

(for example: it cant use >9. because it would miss out 7,6,5,4,3,2,1.

 

anyone understand what i mean?

Link to comment
https://forums.phpfreaks.com/topic/134686-if-statement-help/
Share on other sites

what about

if($player->house_id != 0) //will return true for ever number but 0

or

if($player->house_id > 0) //will return true for every positive number

or

if($player->house_id > 0 && $player->house_id < 17) //will return true for 1-16

 

Scott.

Link to comment
https://forums.phpfreaks.com/topic/134686-if-statement-help/#findComment-701312
Share on other sites

if($player->house_id > 0 && $player->house_id < 17) //will return true for 1-16

 

 

but what if i didnt want for example 12 to return true?

 

Well your OP said anything from 0-16, so which is it? 0-16 or 0-16 except some random number like 12?

 

0-16 except one random number.

 

 

I tried this :

 

if($player->house_id != 0 && $player->house_id != 1) {

header("location: estateagent.php");

    }

 

but got a unexpected T_VARIABLE error

Link to comment
https://forums.phpfreaks.com/topic/134686-if-statement-help/#findComment-701335
Share on other sites

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.