$testsql = "SELECT * FROM `games` WHERE `status` = '0' AND `cat_id` = '$rowcat[id]' ORDER BY rand() DESC LIMIT 0,3";
$testresult = mysql_query($testsql) or die('Error, query failed ' . mysql_error());
$countd = mysql_num_rows($testresult);
mysql_free_result($testresult);
if($countd == 0)
{
$sql = "SELECT * FROM `dir_category` WHERE `parent_id` = '$rowcat[id]' ORDER BY rand() LIMIT 0,1";
$result = mysql_query($sql) or die('Error, query failed ' . mysql_error());
$rowc = mysql_fetch_array($result);
$cat_ids = $rowc[id];
$urlp = $rowc[path];
mysql_free_result($result);
}else{
$cat_ids = $rowcat[id];
$urlp = $rowcat[path];
}
$topsql = "SELECT * FROM `games` WHERE `status` = '0' AND `cat_id` = '$cat_ids' ORDER BY rand() DESC LIMIT 0,3";
$topresult = mysql_query($topsql) or die('Error, query failed ' . mysql_error());
while($toprow = mysql_fetch_array($topresult))
{
$fnt = $toprow['content_name'];
$gnamet = substr($fnt,0,strrpos($fnt,'.'));
?>
=$toprow['title'];?>
}
mysql_free_result($topresult);
?>
$testsql = "SELECT * FROM `games` WHERE `status` = '0' AND `cat_id` = '$rowcat[id]' ORDER BY rand() DESC LIMIT 0,3";
$testresult = mysql_query($testsql) or die('Error, query failed ' . mysql_error());
$countd = mysql_num_rows($testresult);
mysql_free_result($testresult);
if($countd == 0)
{
$sql = "SELECT * FROM `dir_category` WHERE `parent_id` = '$rowcat[id]' ORDER BY rand() LIMIT 0,1";
$result = mysql_query($sql) or die('Error, query failed ' . mysql_error());
$rowc = mysql_fetch_array($result);
$cat_ids = $rowc[id];
$urlps = $rowc[path];
mysql_free_result($result);
}else{
$cat_ids = $rowcat[id];
$urlps = $rowcat[path];
}
$topsqls = "SELECT * FROM `games` WHERE `status` = '0' AND `cat_id` = '$cat_ids' ORDER BY rand() DESC LIMIT 0,3";
$topresults = mysql_query($topsqls) or die('Error, query failed ' . mysql_error());
while($toprows = mysql_fetch_array($topresults))
{
$fnts = $toprows['content_name'];
$gnamets = substr($fnts,0,strrpos($fnts,'.'));
?>
=$toprows['title'];?>
}
mysql_free_result($topresults);
?>