You are currently viewing our boards as a guest. By joining our community you will be able to make posts, communicate privately with other arcade webmasters and talk advantage of the GameFeed™ Distribution Network for 1-click installation of games into your arcade.

$sql="SELECT * FROM games WHERE gameStatus=1 AND gameCat='$id' ORDER BY gamePlaysTotal LIMIT $start,$limit";

replace with

PHP Code:

/**edited by lfhost**/
//$sql="SELECT * FROM games WHERE gameStatus=1 AND gameCat='$id' ORDER BY gamePlaysTotal LIMIT $start,$limit";
$sql="SELECT games.*,catName FROM games LEFT OUTER JOIN categories ON catId = gameCat WHERE gameStatus=1 AND gameCat='$id' ORDER BY gamePlaysTotal LIMIT $start,$limit";

find

PHP Code:

$totalPages=ceil(mysql_num_rows(mysql_query("SELECT * FROM games WHERE gameStatus=1 AND gameCat='$id' ORDER BY gamePlaysTotal"))/$limit);

replace with

PHP Code:

/**edited by lfhost**/
//$totalPages=ceil(mysql_num_rows(mysql_query("SELECT * FROM games WHERE gameStatus=1 AND gameCat='$id' ORDER BY gamePlaysTotal"))/$limit);
$totalPages=ceil(mysql_num_rows(mysql_query("SELECT games.*,catName FROM games LEFT OUTER JOIN categories ON catId = gameCat WHERE gameStatus=1 AND gameCat='$id' ORDER BY gamePlaysTotal"))/$limit);

find

PHP Code:

$sql="SELECT * FROM games WHERE gameName LIKE '%$q%' OR gameDesc LIKE '%$q%' OR gameTags LIKE '%$q%' AND gameStatus=1 ORDER BY gamePlaysTotal LIMIT $start,$limit";

replace with

PHP Code:

/**edited by lfhost**/
//$sql="SELECT * FROM games WHERE gameName LIKE '%$q%' OR gameDesc LIKE '%$q%' OR gameTags LIKE '%$q%' AND gameStatus=1 ORDER BY gamePlaysTotal LIMIT $start,$limit";
$sql="SELECT games.*,catName FROM games LEFT OUTER JOIN categories ON catId = gameCat WHERE gameName LIKE '%$q%' OR gameDesc LIKE '%$q%' OR gameTags LIKE '%$q%' AND gameStatus=1 ORDER BY gamePlaysTotal LIMIT $start,$limit";

find

PHP Code:

$sql="SELECT * FROM games WHERE gameStatus=1 ORDER BY gamePlaysTotal DESC LIMIT $start,$limit";

replace with

PHP Code:

/**edited by lfhost**/
//$sql="SELECT * FROM games WHERE gameStatus=1 ORDER BY gamePlaysTotal DESC LIMIT $start,$limit";
$sql="SELECT games.*,catName FROM games LEFT OUTER JOIN categories ON catId = gameCat WHERE gameStatus=1 ORDER BY gamePlaysTotal DESC LIMIT $start,$limit";

find

PHP Code:

$sql="SELECT * FROM games WHERE gameStatus=1 ORDER BY gameAdded DESC LIMIT $start,$limit";

replace with

PHP Code:

/**edited by lfhost**/
//$sql="SELECT * FROM games WHERE gameStatus=1 ORDER BY gameAdded DESC LIMIT $start,$limit";
$sql="SELECT games.*,catName FROM games LEFT OUTER JOIN categories ON catId = gameCat WHERE gameStatus=1 ORDER BY gameAdded DESC LIMIT $start,$limit";

find

PHP Code:

$sqlTotal="SELECT * FROM games WHERE gameStatus=1";

replace with

PHP Code:

/**edited by lfhost**/
//$sqlTotal="SELECT * FROM games WHERE gameStatus=1";
$sqlTotal="SELECT games.*,catName FROM games LEFT OUTER JOIN categories ON catId = gameCat WHERE gameStatus=1";

Yeah, the outer joins are useful, you just have to make sure you select the fields you want and not just use * as that would be too much overhead and a waste of resources. Here were just pull the game fields and the catname.

So its much lighter than pulling the query on every record.

if you dont want to use a join, you could query the cat DB once, then from the array, pull back the category name by using the cat id as the array index. As the category table is small then the array wouldnt be too heavy.

Theres more than one way to approach it, I just prefer joining and let mysql do the work.
Caching the SQL would be even better :P