Well here is the modified version of your script. Lemme know if it works and I will see what I can do to help you:
PHP Code:
<?php
include("functions/functions.php");
include("functions/functions_users.php");
include("functions/functions_adopts.php");
include("inc/lang.php");
//***************//
// START SCRIPT //
//***************//
$article_title = "Random adoptables";
$article_content .= "<br><h3>{$lang_randomadopts}</h3>{$lang_randomtext}<br>
<br /><form>
<input type='button' onClick='history.go(0)' value='Refresh'>
</form><br><table>
<tr>
<th>Adoptable Image: </th>
<th>Adoptable Name: </th>
<th>Owned By: </th>
<th>Total Clicks: </th>
<th>Current Level: </th>
</tr>";
// Loop out code...
$query = "SELECT * FROM ".constant("PREFIX")."owned_adoptables, ".constant("PREFIX")."adoptables, ".constant("PREFIX")."levels
WHERE ".constant("PREFIX")."adoptables.type = ".constant("PREFIX")."owned_adoptables.type
AND ".constant("PREFIX")."levels.thisislevel = ".constant("PREFIX")."owned_adoptables.currentlevel
AND ".constant("PREFIX")."levels.adoptiename = ".constant("PREFIX")."adoptables.type ORDER BY RAND() DESC LIMIT 10";
$stmt = $adopts->query($query);
//Loop out code
$counter = 0;
while($row = $stmt->fetchObject()){
$date = date('Y-m-d');
$ip = $_SERVER['REMOTE_ADDR'];
$where_clause = ($isloggedin == "yes")
?"adoptableid='{$row->aid}' and username = '{$loggedinname}' and date = '{$date}'"
:"adoptableid='{$row->aid}' and ip = '{$ip}' and date = '{$date}'";
$vote = $adopts->select("vote_voters", array("void"), $where_clause)->fetchColumn();
if(is_numeric($vote)){
// The adoptable has been clicked by the user, so we will not load this data
continue;
}
if ($row->currentlevel==0) $image = $row->eggimage;
elseif ($row->$usealternates=='yes') $image = $row->alternateimage;
else $image = $row->primaryimage;
$article_content .= "<tr>
<td><center><a href='levelup.php?id={$row->aid}'><img src='{$image}' border=0></a></center></td>
<td><center>{$row->name}</center></td>
<td><center><a href='profile.php?user={$row->owner}'>{$row->owner}</a></center></td>
<td><center>{$row->totalclicks}</center></td>
<td><center>{$row->currentlevel}</center></td>
</tr>";
$counter++;
if($counter >= 10){
// Already loaded ten adoptables, time to break out of the loop.
break;
}
}
$article_content .= "</table><br><form>
<input type='button' onClick='history.go(0)' value='Refresh'>
</form>";
//***************//
// OUTPUT PAGE //
//***************//
echo showpage($article_title, $article_content, $date);
?>