I am working on content-based filtering algorithm using PHP. I'm trying to retrieve user data from the table using the query "$user = [$db, "SELECT interest FROM jobseeker WHERE username = '$username'"];"
it shows the warning as in comment:
protected function processUser($user)
{
$result = [];
foreach ($user as $tag) {
$result[$tag] = 1.0; //illegal offset type on this line
}
return $result;
}
Also while fetching objects from the table using the query
$objects = [$db, "SELECT job_title, category FROM job_data"];
it shows another warning as in comment:
protected function processObjects($objects)
{
$result = [];
foreach ($objects as $object => $tags) {
foreach ($tags as $tag) //invalid argument supplied for foreach()
{
What would be the valid argument for this case?? I've tried this query as for this case:
$objects = [($db,"SELECT job_title from jobs") => [$db, "SELECT name FROM categories"]];
Still it didn't work as it gave error unexpected on this query