milezteg

Topic: Help with a Function

In the sidebar on the home page you can see a list of all jobs in all cities.  I have a huge list of cities so I am trying to shorten this list a bit by only showing cities with at least 2 jobs in them.

Here is the function:

Code:
    public function GetNumberOfJobsInOtherCities()
    {
        global $db;
        
        $sql = 'SELECT COUNT(id) AS total FROM '.DB_PREFIX.'jobs WHERE is_temp = 0 AND is_active = 1 AND city_id IS NULL';

        $result = $db->query($sql);
        
        $row = $result->fetch_assoc();
        
        return $row['total'];
    }

I have tried a lot of things but I not a SQL guru.  The following did not work: 

Code:
$sql = 'SELECT COUNT(id) AS total FROM '.DB_PREFIX.'jobs WHERE is_temp = 0 AND is_active = 1 AND city_id IS NULL GROUP BY id HAVING total > 3';

Any ideas guys??

putypuruty

Re: Help with a Function

Hi!

To achieve what you want, open _includes/class.Job.php and find this function GetJobsCountPerCity.
Inside it, you'll see if ($count > 0). Change 0 to whatever value you wish (if you want at least 2 jobs, then change 0 to 1).

Please note that 'Sidebar - show only cities with jobs' must be set to yes for this to work correctly.

milezteg

Re: Help with a Function

Hey you're awesome!  Missed that somehow ... thanks so much for the quick reply smile