Can't test it, but this should work:
PHP Code:
$query = $db->query("SELECT * FROM redirect ORDER BY hits DESC");
if ($db->num_rows($query) == 0) {
print "Nothing here";
} else {
while($row = $db->fetch_array($query)){
if($row['hits'] < 100){
$color = $color100;
}
print "<div align=\"left\">";
print "<table COLS=3 border=\"0\" width=\"100%\"><tr><td ALIGN=LEFT with=\"400\"><b><a href=\"" . $row['url'] . "\">" . $row['url'] . "</a></b></td>";
print "<td align=right WIDTH=\"60\"><b>" . $row['hits'] . "</b></td>";
print "<td align=left WIDTH=\"" . $row['hits'] . "\" BGCOLOR=\"" . $color . "\"> </td></tr>";
print "</table>\n";
}
}
Some tips:
- Look at the functions of the vB_Database class in /includes/class_core.php, you will see what all the functions do and what parameters they require.
- query_first only returns the first row of the query, so it can not be used in this case since you want to loop through all of the results.
- Always escape PHP variables outside of the quotes, makes it easier to debug and to overview code.
- Write SQL syntax with uppercase characters.
- Only set new variables if you absolutely have to, makes code cleaner.