Search code examples
phpflourishlib

Trying to set php variable from sql field


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


Solution

  • Try with:

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

    You must repeat the var.