D
dhvrm
Guest
It comes up empty because $votes isn't declared.
It's nearly impossible to tell what you are trying to accomplish, but your code is a total mess.
<?php
$link = mysql_connect('host', 'user', 'pass') or die('Cannot connect to db server');
mysql_select_db('dbname') or die('Cannot select database');
$rs = mysql_query("SELECT * FROM chewytable ORDER BY rating DESC") or die('Cannot parse query');
if(mysql_num_rows($rs) == 0) {
die('No records found');
}
else {
$row = mysql_fetch_array($rs);
}
echo "<table>\n";
echo "<tr>\n";
echo "<td>$row
It's nearly impossible to tell what you are trying to accomplish, but your code is a total mess.
<?php
$link = mysql_connect('host', 'user', 'pass') or die('Cannot connect to db server');
mysql_select_db('dbname') or die('Cannot select database');
$rs = mysql_query("SELECT * FROM chewytable ORDER BY rating DESC") or die('Cannot parse query');
if(mysql_num_rows($rs) == 0) {
die('No records found');
}
else {
$row = mysql_fetch_array($rs);
}
echo "<table>\n";
echo "<tr>\n";
echo "<td>$row
HTML:
</td>\n";
echo "<td>";
echo "<strong>$row[name]</strong>";
echo "<strong>Rating:</strong> ";
$rate = $row['rating'] / ($row['votes'] + 1)
echo round( $rate, 2);
echo "<strong>Number of ratings: </strong>";
echo $row['votes'];
echo "<strong>Votes plus one: </strong>";
echo $row['votes'] + 1;
echo "<strong>Description:</strong> ";
echo $row['description'];
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
?>