Question

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 :)

Was it helpful?

Solution

Try with:

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

You must repeat the var.

OTHER TIPS

maybe you can try something like ...

$sortingMethodId = $company->getSortingMethodId();
$this->data["show_hours"] = $sortingMethodId == 3 ? true : ($sortingMethodId == 5 ? true : ($sortingMethodId == 7 ? true : false));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top