dimanche 1 avril 2018

Laravel 5.5 Undefined variable: result

Here's the PHP:

    if($criteria == 'schools'){
        $result = $result->where('name', 'LIKE', '%'.$searchItem.'%');
    }elseif($criteria == 'bachelorsdegree'){
        $result = $result->where('undergradcourses', 'LIKE', '%'.$searchItem.'%');
    }elseif($criteria == 'mastersdegree'){
        $result = $result->where('postgradcourses', 'LIKE', '%'.$searchItem.'%');
    }elseif($criteria == 'technicalvocational'){
        $result = $result->where('technicalandvocationalcourses', 'LIKE', '%'.$searchItem.'%');
    }elseif($criteria == 'certificateshortcourse'){
        $result = $result->where('shortcoursesandcertifications', 'LIKE', '%'.$searchItem.'%');
    }

The error occurs at this line:

        $result = $result->where('undergradcourses', 'LIKE', '%'.$searchItem.'%');

It started when I took out this line:

 $result = schools::where('location', 'LIKE', '%'.$searchLocation.'%');

Problem is: I took out the input field in the main search form that had the searchLocation field so I didn't want "searchLocation" to be in the search parameters anymore when you did a search. The fields that exist in the search form is searchItem and the dropdown menu for degree types under the criteria of schools.

Any ideas?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire