Is there a way to take this code:
### Number of games from this category to show ###
$numofgames = 2;
### Total Games ###
$count = mysql_query("SELECT COUNT(*) as games FROM games") or die(mysql_error());
$count = mysql_fetch_object($count);
$ttlgames = $count->games;
### Loop to get random games and print them out. ###
for ($x = 1; $x <= $numofgames; $x++) {
do {
### Selecting a random game. ###
$random = rand(1,$ttlgames);
### Gets the info on this game ###
$infoongame = mysql_query("SELECT * FROM games WHERE gId = '$random'") or die(mysql_error());
$infongame = mysql_fetch_object($infoongame);
### Checks to make sure it is ok ###
if ($infoongame->gVisible == 1 && $infoongame->gInCategory == $categories->cId) {
$x = 1;
} else {
$x = 0;
}
}
while ($x != 1);
echo "
<td onClick=\"window.location.href='" . $_SERVER['PHP_SELF'] . "?data=" . $categories->cId . ",1'; return true;\">
<img src=\"./images/" . $infoongame->gThumb . "\" alt=\"" . $infoongame->gName . "\" width=\"50\" height=\"50\" /> <br>
<strong>$infoongame->gName</strong>
</td>
";
}
Is there a way to take that code and make it so that it does not take forever for the page to load, because currently it is just taking way to long. Basically it has to take two random games from the database from the right category and they have to be visible. thanx in advanced.