Link to home
Start Free TrialLog in
Avatar of Pete Winter
Pete WinterFlag for United Kingdom of Great Britain and Northern Ireland

asked on

php if or

Can some one please explain to me why the below does not work for me.

if($row_rs_media_new['category'] == 'EFI VUTEk' || 'EFI VUTEk Accessories') {
	  $roll_price = $row_rs_media_new['cost']; 
 }

Open in new window


but if I separate to this below is does?

if($row_rs_media_new['category'] == 'EFI VUTEk') {
	  $roll_price = $row_rs_media_new['cost']; 
  }
  
  if($row_rs_media_new['category'] == 'EFI VUTEk Accessories') {
	  $roll_price = $row_rs_media_new['cost']; 
  }

Open in new window


What am I doing wrong with the OR operator? I just want to ask if $row_rs_media_new['category'] is equal to 'EFI VUTEk' or 'EFI VUTEk Accessories'.
SOLUTION
Avatar of Marco Gasi
Marco Gasi
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Pete Winter

ASKER

Thanks to you both. That makes sense, but why does the below not work for me then?

<?php if ($row_rs_media_new_group['category'] != 'EFI VUTEk Accessories' || $row_rs_media_new_group['category'] != 'Ink Misc') { ?>
    <td bgcolor="#DDDDDD"><?php echo ucwords(strtolower($row_rs_media_new['ink_colour'])); ?></td>
    <?php } ?>

Open in new window


but this does...

 <?php if ($row_rs_media_new_group['category'] != ('EFI VUTEk Accessories' || 'Ink Misc')) { ?>
    <td bgcolor="#DDDDDD"><?php echo ucwords(strtolower($row_rs_media_new['ink_colour'])); ?></td>
    <?php } ?>

Open in new window


Does it work differently when I say not equal != ?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Many thanks. Wanted to share points for the explanation.
You are welcome.