habe ein Bildervote-System entwickelt.Beim klick auf ein Bild kann man seinen Vote abgeben und dabei wird danach das nächste Bild gezeigt wo man dann auch voten kann.
Nun mein Problem.
Ich habe in der db 10 Bilder. er soll nur die 10 Bilder nacheinander beim voten anzeigen und dann aufhören.Zur Zeit kann man die Bilder ohne ende voten weil sie immer und immer weiterlaufen.
Ich möchte es bei 10 abbrechen.
Nun mein Problem.
Ich habe in der db 10 Bilder. er soll nur die 10 Bilder nacheinander beim voten anzeigen und dann aufhören.Zur Zeit kann man die Bilder ohne ende voten weil sie immer und immer weiterlaufen.
Ich möchte es bei 10 abbrechen.
Code:
<?
@include("config.php");
@mysql_connect($db_server,$db_user,$db_password) or die("Datenbankverbindung fehlgeschlagen");
@mysql_select_db($db_name) or die("Datenbankauswahl fehlgeschlagen");
if($_POST["vote"]){
mysql_query("UPDATE ".$db_table_pictures." SET points=points+".$_POST["vote"].",votes=votes+1 WHERE id=".$_POST["id"].";");
}
if(strlen($_GET["comment_name"])>2 && strlen($_GET["comment_text"])>2){
$name = $_GET["comment_name"];
$name = str_replace("<","<",$name);
$name = str_replace(">",">",$name);
$name = stripslashes($name);
$text = $_GET["comment_text"];
$text = str_replace("<","<",$text);
$text = str_replace(">",">",$text);
$text = stripslashes($text);
mysql_query("INSERT INTO ".$db_table_comments." VALUES('',".$_GET["show"].",'$name','$text',".time().");");
}
if(!$_GET["show"] and !$_POST["show"]){
$result = mysql_query("SELECT * FROM ".$db_table_pictures.";");
while(list($ids[]) = mysql_fetch_row($result));
while(true){
srand((double)microtime()*1000000);
$show = rand(1,mysql_num_rows($result));
if(array_search($show,$ids)){
break;
}
}
}
else{
$show = $_GET["show"] ? $_GET["show"] : $_POST["show"];
}
$row = mysql_fetch_array(mysql_query("SELECT * FROM ".$db_table_pictures." WHERE id=$show;"));
list($next) = mysql_fetch_row(mysql_query("SELECT id FROM ".$db_table_pictures." WHERE id>$show ORDER BY id ASC LIMIT 0,1;"));
if($row["points"] != 0){
$row["points"] = number_format($row["points"]/$row["votes"],2,",","");
}
if(!$next){
list($next) = mysql_fetch_row(mysql_query("SELECT id FROM ".$db_table_pictures." WHERE id>1 ORDER BY id ASC LIMIT 0,1;"));
}
echo $header;
echo "
<form action=\"".$PHP_SELF."\" method=\"post\">
<table align=\"center\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">
<tr>
<td rowspan=\"2\">schlecht</td>
<td rowspan=\"2\" width=\"10\"> </td>";
for($i=1;$i<=$max_points;$i++){
echo "
<td align=\"center\">$i</td>";
}
echo "
<td rowspan=\"2\" width=\"10\"> </td>
<td rowspan=\"2\">gut</td>
</tr>
<tr>";
for($i=1;$i<=$max_points;$i++){
echo "
<td align=\"center\"><input type=\"radio\" name=\"vote\" value=\"$i\" onClick=\"submit();\"></td>";
}
echo "
</tr>
</table>
<input name=\"show\" type=\"hidden\" value=\"$next\">
<input name=\"id\" type=\"hidden\" value=\"".$row["id"]."\">
</form>
</td>
</tr>
<tr>
<td colspan=\"2\" height=\"8\"> </td>
</tr>
<tr>
<td align=\"center\" colspan=\"2\" height=\"".$img_height."\"><img alt=\"\" border=\"0\" src=\"".$img.$show.$img_format_info."\"></td>
</tr>
<tr>
<td colspan=\"2\" height=\"10\"> </td>
</tr>
<tr>
<td valign=\"top\" width=\"50%\">Bild von <b>".$row["creator"]."</b><br><br>".$row["comment"]."<br><br></td>
<td align=\"right\" valign=\"top\" width=\"50%\">Punkte: <b>".$row["points"]."</b> (".$row["votes"]." Votes)<br><br></td>
</tr>
<td colspan=\"2\">
<hr>";
$result = mysql_query("SELECT * FROM ".$db_table_comments." WHERE id_pic=".$row["id"]." ORDER BY date DESC;");
if(mysql_num_rows($result) == 0){
echo "
Keine Kommentare";
}
else{
while($row = mysql_fetch_array($result)){
echo "
<b>".$row["name"]."</b> schrieb am ".date("d.m.",$row["date"])." um ".date("H:i",$row["date"]).":<br>
".$row["text"]."
<br><br>";
}
}
echo "
<hr>
<b>Kommentar schreiben:</b>
<form action=\"".$PHP_SELF."\" method=\"get\">
<table align=\"center\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\">
<tr>
<td>Name:</td>
<td><input maxlength=\"50\" name=\"comment_name\" size=\"30\" type=\"text\"></td>
</tr>
<tr>
<td valign=\"top\">Kommentar:</td>
<td><textarea cols=\"70\" name=\"comment_text\" onkeyup=\"this.value=this.value.slice(0,".$comment_size.")\" rows=\"6\"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type=\"submit\" value=\"Kommentar schreiben\"></td>
</tr>
</table>
<input name=\"show\" type=\"hidden\" value=\"$show\">
</form>";
echo $footer;
@mysql_close();
?>