Jump to content

TopRoutes function


steelerboi

Recommended Posts

Hi Nabeel,

Just thought you might like to know that the TopRoutes function in StatsData.class.php needs a slight change to the SQL query to make it work.

The query as it currently stands is

$sql = 'SELECT * 
				FROM `'.TABLE_PREFIX.'schedules`';

		if($airline_code != '')
		{
			$sql .= " AND `code`='{$airline_code}' GROUP BY `code`";
		}

		$sql ='	ORDER BY `timesflown` DESC
				LIMIT 10';

However, this doesn't work as the 'AND' needs to be a 'WHERE'. Also, there's a period missing before the = in the 2nd sql join.

The other thing which I had to change in order to get it working on my site, was to remove the GROUP BY `code` since no results were returned if this was left in. I only have the one code anyhow, so it's no biggie for me :)

Anyway, here's the query which I now use:

$sql = 'SELECT *
                                       FROM `'.TABLE_PREFIX.'schedules`';

                       if($airline_code != '')
                       {
                               $sql .= " WHERE `code`='{$airline_code}'";
                       }

                       $sql .= ' ORDER BY `timesflown` DESC
                                       LIMIT 10';

Kind regards,

Nige.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...