Witam! Mam bardzo dobry skrypt oceny w PHP z użyciem MySQL-a. Liczy on średnią i... właśnie o tę średnią chodzi... jak wyciągnąć z każdej gry średnią? Tzn. że mamy np. w pliku gra.php?id=9898989 średnią ocen: 6. i chciałbym żeby na stronie głównej pisało że gra wyścigi ma średnią 6 itp. nie wiem jak to wyciągnąć z tego kodu...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="Content-type" content="text/html; charset=windows-1250">
<style type="text/css">
body {
background: #fff;
}
</style>
<?php
$id = $_GET['id'];
$ocena = $_POST['ocena'];
{
echo "NIE PODALES WARTOSCI ZMIENNEJ ID!!"; } else {
include("cofing_sql.php");
$dni = "1"; // jak dlugo ma trzmac sie blokada, o - blokada wylaczona
$rt=mysql_query("DELETE FROM blok_ip WHERE wygasa='$data' AND ids='$id'");
$ip=$_SERVER[REMOTE_ADDR];
$pytaniea="SELECT * FROM blok_ip WHERE ip='$ip' AND ids='$id'";
if($ip_jest=="0")
{
if(!$ocena)
{ } else {
$zapytanie = "INSERT INTO ocena SET ocena='$ocena', ids='$id'";
$zapytaniedwa = "INSERT INTO blok_ip SET ip='$ip', wygasa='$plusdata', ids='$id'";
}
}
$pytanie="SELECT * FROM ocena WHERE ids='$id'";
$suma="0";
$suma=$suma+$xy[ocena];
}
if($ile>0)
{
$sr=$suma/$ile;
} else {
$srednia="0";
}
if(!$ocena)
{
echo "<center><font color="green
" size="2" face="Arial
"><b>Oceń tę grę:</font><br><br> "; }
if($ip_jest=="0")
{
if(!$ocena)
{
echo "<form action='' method="post
"> <input type="hidden" name="id" value="$id">
<input type="submit" name="ocena" value="1">
<input type="submit" name="ocena" value="2">
<input type="submit" name="ocena" value="3">
<input type="submit" name="ocena" value="4">
<input type="submit" name="ocena" value="5">
<input type="submit" name="ocena" value="6">
<input type="submit" name="ocena" value="7">
<input type="submit" name="ocena" value="8">
<input type="submit" name="ocena" value="9">
<input type="submit" name="ocena" value="10">
</from>";
} else {
echo "<center><font color="green
" size="2" face="Arial
"><b>Twoja ocena została przyjęta...</b>"; if($dni>0)
{
echo "<br><b><font color="red
">Średnia głosów:</b> $srednia</b>"; } else {
echo "<form action='' method="post
"> <input type="hidden" name="id" value="$id">
<input type="submit" name="ocena" value="1">
<input type="submit" name="ocena" value="2">
<input type="submit" name="ocena" value="3">
<input type="submit" name="ocena" value="4">
<input type="submit" name="ocena" value="5">
<input type="submit" name="ocena" value="6">
<input type="submit" name="ocena" value="7">
<input type="submit" name="ocena" value="8">
<input type="submit" name="ocena" value="9">
<input type="submit" name="ocena" value="10">
</from>";
}
}
} else {
echo "<font color="red
"><br><B>Oddałeś już głos.</b>"; }
}
?>