使用评级系统编辑PHP代码

时间:2013-07-02 03:05:55

标签: php mysql ajax rating-system

我正在尝试用它的速率显示我的数据库的游戏,所有这些都在一个页面中。我得到的结果完全不同于我想要的,我得到每个游戏中所有游戏的总费率。我想在我的index.php页面中显示我的游戏及其各自的费率,我知道我应该使用PDO,但我不会再写它,这是我的实际代码:

$varCategoria_GameData = "0";
if (isset($_GET["cat"])) {
$varCategoria_GameData = $_GET["cat"];
}
mysql_select_db($database_gameconnection, $gameconnection);
$query_GameData = sprintf("SELECT * FROM `jogos` ORDER BY  RAND()      
");

$GameData = mysql_query($query_GameData, $gameconnection) or die(mysql_error());
$row_GameData = mysql_fetch_assoc($GameData);

$totalRows_GameData = mysql_num_rows($GameData);  

<?php  do { ?>

<div align="center" id="thumb">

<div id="screen_game">
<?php



$ids[] = $row_GameData['idGames'];

?>
<?php
for ($i = 0; $i < count($ids); $i++) {

$id = $ids[$i];



$v  = $row_GameData['total_votes'];
$tv = $row_GameData['total_value'];
if ($v)
    $rat = $tv / $v;
else
    $rat = 0;



$j  = $ids[$i];
$id = $ids[$i];
echo '<div class="">
   Rate Item ' . $j . '
     <div id="' . $id . '" class="">';
for ($k = 1; $k < 6; $k++) {
if ($rat + 1 > $k)
    $class = "star_" . $k . "  ratings_stars ratings_vote";
else
    $class = "" . $k . " ratings_stars ratings_blank";
echo '<div class="' . $class . '"></div>';
}
echo ' 
</div></div>';
}
?> 
  </div>

<a href="legendofgames/gameview.php?recordID=<?php echo $row_GameData['idGames']; ?>">     <img src="../legendofgames/documentos/games/<?php echo $row_GameData['strImage']; ?>" width="130" height="110"/></a>
<div align="center" id="gametext"><?php echo $row_GameData['strNome']; ?> </div>
</div>


<?php } while ($row_GameData = mysql_fetch_assoc($GameData)); ?>

0 个答案:

没有答案