<div class="grid--cell fl1 lh-lg">
<div class="grid--cell fl1 lh-lg">
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, <a href="/help/reopen-questions">visit the help center</a>.
</div>
</div>
</div>
<div class="grid--cell mb0 mt8">Closed <span title="2013-06-11 10:15:27Z" class="relativetime">6 years ago</span>.</div>
</div>
</aside>
So, I grabbed this code from here. and I changed it a little to fit my db and display the rate based on my idGames, it's working fine, but now I want to do something like this.
How can I display the rates when I enter in the game page and rate that particular game?
I have an index.php
page, on which I show all my games, and I have a gameview.php
that is the path for each game in index.php
, so when you click in the game in index that game is displayed in gameview. Is there a way to implement that code to rate the games in gameview.php
? I don't know if I'm being clear enough, but take that link as an example, it's exactly what I want. And I know that MYSQL
is deprecated, but I don't know MYSQLi
or PDO
. So if you can help me with this I appreciate.
<?php
include_once('settings.php');
connect();
$query = "SELECT idGames FROM jogos";
$result = mysql_query($query);
$ids = array();
while ($row = mysql_fetch_assoc($result)) {
$ids[] = $row['idGames'];
}
?>
<html>
<head>
</head>
<body>
<?php
for ($i = 0; $i < count($ids); $i++) {
$rating_tableName = 'jogos';
$id = $ids[$i];
$q = "SELECT total_votes, total_value FROM $rating_tableName WHERE idGames=$id";
$r = mysql_query($q);
if (!$r)
echo mysql_error();
while ($row = mysql_fetch_array($r)) {
$v = $row['total_votes'];
$tv = $row['total_value'];
if ($v)
$rat = $tv / $v;
else
$rat = 0;
}
$j = $ids[$i];
$id = $ids[$i];
echo '<div class="product">
Rate Item ' . $j . '
<div id="rating_' . $id . '" class="ratings">';
for ($k = 1; $k < 6; $k++) {
if ($rat + 1 > $k)
$class = "star_" . $k . " ratings_stars ratings_vote";
else
$class = "star_" . $k . " ratings_stars ratings_blank";
echo '<div class="' . $class . '"></div>';
}
echo ' <div class="total_votes"><p class="voted"> Rating: <strong>' . @number_format($rat) . '</strong>/5 (' . $v . ' vote(s) cast)
</div>
</div></div>';
}
?>
</body>
</html>
</div>