简体   繁体   中英

How to add 2 objects to php code

I have 6 product pages with id from 1 to 6. In the shopping cart page I have this code:

<?php if($objcartRS["catid"]==1 ){ echo "xxx"; ?>   <?php } else { echo "yyy"; }?>

My problem is how can I add another page for ex the one with id 2 so it will be just 1 and 2 that will take the name xxx and the rest of the pages yyy ?

I hope someone can help me.

As you said based on that you have to do very simple change in you condition that is add another condition in if with || operator like below:-

<?php if($objcartRS["catid"]==1 || $objcartRS["catid"] == 2){ echo "xxx"; ?> <?php } else { echo "yyy"; }?>

Note:- Please note that $objcartRS["catid"] value must be integer type otherwise your condition will false. In that case you need to typecast your value to integer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM