<?PHP
$anzahl=5; //Anzahl der Einträge pro Seite
include("connect.php");
$show = $_GET["show"];
if(!$show) {
$show=1;
}
$limit=$show*5;
$limitanfang=($show-1)*5;
$abfrage1=Mysql_query("select * from witzfr");
$number=mysql_num_rows($abfrage1);
function starrating($durchschnitt) {
$half_round = number_format(round(($durchschnitt*2), 0)/2,1,'.','');
$durchschnitt = '<img src="../../images/stern/'.str_replace('.','',$half_round).'5.gif" width="54" height="10" border="0" />';
return $durchschnitt;
}
?>
<?
$query1="select * from witzfr order by datum desc limit ".$limitanfang.",".$anzahl;
$abfrage1=Mysql_query($query1);
while($row=mysql_fetch_object($abfrage1)) {
$datu = getdate($row->datum);
$datum = $datu[mday].".".$datu[mon].".".$datu[year];
echo $row->text;
echo "<p></p>";
echo (starrating($durchschnitt));
?>
<form action="witz.php" method="get">
Bewerten:
<select name="vote" onChange="this.form.submit();window.open('vote.php','_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=125,height=100,top=0,left=0');location.reload();" style="width:77px; font-family:verdana; color:#000000; font-size:8pt">
<option value="0" name="vote">----------</option>
<option value="1" name="vote">sehr gut</option>
<option value="2" name="vote">gut</option>
<option value="3" name="vote">befriedigend</option>
<option value="4" name="vote">ausreichend</option>
<option value="5" name="vote">mangelhaft</option>
<option value="6" name="vote">ungenügend</option>
</select>
<input type="hidden" name="id" value="<?php echo $row->id; ?>">
<input type="hidden" name="action" value="voting">
<a href="print.php?id=<? echo $row->id; ?>" onclick="window.open(this.href,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=300,height=200,top=0,left=0'); return false" target="_blank"><img src="../../images/drucker.gif" border="0" height="20px" title="Witz drucken"></a>
<a href="send.php?id=<? echo $row->id; ?>" onclick="window.open(this.href,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=400,height=600,top=0,left=0'); return false" target="_blank"><img src="../../images/email.gif" border="0" height="12px" title="Witz an Freund senden"></a>
</form>
<?
if($vote > "0"){
if($_GET["action"] =="voting") {
$query="update witzfr SET vote_gesamt = vote_gesamt + '".$vote."', vote_anzahl = vote_anzahl + 1, durchschnitt = vote_gesamt/vote_anzahl WHERE id=".$id."";
$abfrage=mysql_query($query);
}
}
}
?>
<p></p>
<table width="100%" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="33%" valign="top" bgcolor="#ededed" align="left">
<?PHP
if($limitanfang > 0) { echo "<a href=\"javascript:history.back(-1)\">Vorherige Seite</a>"; }
?>
</td>
<td width="34%" valign="top" bgcolor="#ededed" align="center">
<?
echo "Seite ".$show. " von ".ceil($number/5) ;
?>
</td>
<td width="33%" valign="top" bgcolor="#ededed" align="right">
<?PHP
$seiten=$show+1;
if($number - $limit > 0) { echo "<a href=\"witz.php?show=$seiten\">Nächste Seite</a>"; }
?>
</td>
</tr>
</table>