0

Trying to set a variable where show_hours is true if SortingMethodId is equal to 3, 6 or 7. Right now its only if the SortingMethodId is equal to 3 (from MySQL db), as below:

$this->data["show_hours"] = ($company->getSortingMethodId() == 3);

So I tried:

$this->data["show_hours"] = ($company->getSortingMethodId() == 3 OR == 6 OR == 7);

and only returned an error.... thoughts? I am only a beginner trying to hash up some existing code in our app, so be easy :)

tereško
  • 58,060
  • 25
  • 98
  • 150
firecasey
  • 117
  • 9
  • When posting questions in the future, please remember to include what the error says as this will aid users in determining the problem :) – Ren Dec 07 '12 at 16:23

2 Answers2

1

Try with:

$sortingMethodId = $company->getSortingMethodId();
$this->data["show_hours"] = ($sortingMethodId == 3 || $sortingMethodId == 6 || $sortingMethodId == 7);

You must repeat the var.

jacoz
  • 3,508
  • 5
  • 26
  • 42
0

maybe you can try something like ...

$sortingMethodId = $company->getSortingMethodId();
$this->data["show_hours"] = $sortingMethodId == 3 ? true : ($sortingMethodId == 5 ? true : ($sortingMethodId == 7 ? true : false));
martskins
  • 2,920
  • 4
  • 26
  • 52