Könntest du mir mal erklären wie du das meinst?
Beiträge von Traumbullys
-
-
Kennt Jemand diese Programme? Wo liegt der gravierende Unterschied außer natürlich im Preis.
Beide sind von Data Becker.
-
Nicht mehr ganz, ich habe selber einige Sachen geändert damit die voteing Ergebnisse nicht mehr angezeigt werden. Jetzt sieht das so aus:
PHP
Alles anzeigen<?php //load configuration require("config.php"); //connect to database @mysql_connect($db_server,$db_user,$db_password) or die("Database server connection failed. Check variables \$db_server, \$db_user and \$db_password in config.php"); @mysql_select_db($db_name) or die("Selecting database failed. Check variable \$db_name in config.php"); //number of images $count = @mysql_num_rows(@mysql_query("SELECT id FROM $db_table_pictures WHERE id>1 && votes>=$min_votes;")); $show = $_POST['show'] ? $_POST['show'] : 10; $show = $show > $count ? $count : $show; $result = @mysql_query("SELECT id,creator,comment,votes,points,points/votes as avg FROM $db_table_pictures WHERE id>1 ORDER BY avg DESC LIMIT 0,$show;"); //print header echo $header; //print html ?><form action="toplist.php" method="post"> <table bgcolor="#efefef" border="0" cellpadding="5" cellspacing="5" width="<?php echo $img_width; ?>"> <tr> <td align="center"> Liste <select name="show"><?php //select toplist for($i=10;$i<$count;$i+=10){ ?><option value="<?php echo $i; ?>"><?php echo $i; ?></option><?php } ?><option value="<?php echo $count; ?>">all</option> </select> <input type="submit" value="ok"> </td> </tr> </table> </form> <table border="0" cellpadding="0" cellspacing="15" width="<?php echo $img_width; ?>"><?php <?php //load configuration require("config.php"); //connect to database @mysql_connect($db_server,$db_user,$db_password) or die("Database server connection failed. Check variables \$db_server, \$db_user and \$db_password in config.php"); @mysql_select_db($db_name) or die("Selecting database failed. Check variable \$db_name in config.php"); //number of images $count = @mysql_num_rows(@mysql_query("SELECT id FROM $db_table_pictures WHERE id>1 && votes>=$min_votes;")); $show = $_POST['show'] ? $_POST['show'] : 10; $show = $show > $count ? $count : $show; $result = @mysql_query("SELECT id,creator,comment,votes,points,points/votes as avg FROM $db_table_pictures WHERE id>1 ORDER BY avg DESC LIMIT 0,$show;"); //print header echo $header; //print html ?><form action="toplist.php" method="post"> <table bgcolor="#efefef" border="0" cellpadding="5" cellspacing="5" width="<?php echo $img_width; ?>"> <tr> <td align="center"> Liste <select name="show"><?php //select toplist for($i=10;$i<$count;$i+=10){ ?><option value="<?php echo $i; ?>"><?php echo $i; ?></option><?php } ?><option value="<?php echo $count; ?>">all</option> </select> <input type="submit" value="ok"> </td> </tr> </table> </form> <table border="0" cellpadding="0" cellspacing="15" width="<?php echo $img_width; ?>"><?php //display images for($r=1;$row=mysql_fetch_array($result);$r++){ $points = $row['votes'] ? number_format($row['points'] / $row['votes'],2,".","") : 0; ?><tr> <td> <a href="index.php?show=<?php echo $row['id']; ?>"><img align="left" hspace="5" alt="" border="0" height="100" src="<?php echo $img.$row['id'].$img_format_info; ?>" width="100"></a> <b>Bild <?php echo $r; ?></b> <br><br> <br><br> <b><?php echo $row['creator']; ?></b><br> <?php echo $row['comment']; ?> </td> </tr><?php } ?></table><?php //no images in toplist if($count == 0){ ?><br><br>No images in toplist.<?php } //print footer echo $footer; //close database connection @mysql_close(); ?> <br><br> <br><br> <b><?php echo $row['creator']; ?></b><br> <?php echo $row['comment']; ?> </td> </tr><?php } ?></table><?php //no images in toplist if($count == 0){ ?><br><br>No images in toplist.<?php } //print footer echo $footer; //close database connection @mysql_close(); ?>
Das habe ich sicher eher stümperhaft gelöst, aber es hat funktioniert.
Ich vermute das mit den Spalten ändert man irgendwo hier:
PHP//display images for($r=1;$row=mysql_fetch_array($result);$r++){ $points = $row['votes'] ? number_format($row['points'] / $row['votes'],2,".","") : 0; ?><tr> <td> <a href="index.php?show=<?php echo $row['id']; ?>"><img align="left" hspace="5" alt="" border="0" height="100" src="<?php echo $img.$row['id'].$img_format_info; ?>" width="100"></a> <b>Bild <?php echo $r; ?></b>
Aber ich weiß nicht genau wie...
-
Vielen Dank Bandit, genau da schien der Hase im Pfeffer gelegen zu haben!
Zusammen mit den Änderungen von Pion und dem bisschen was ich selber bewerkstelligen konnte läuft das Script jetzt so wie ich mir das Vorgestellt habe.
Vielen, vielen Dank.Wenn ihr wollt könnt ihr ja mal schauen, auch keine kleinen fledermausohrigen Hunde mögt.
http://www.franzoesische-und-englische-bulldoggen-ev.de/Image_voting/index.phpDie einzige Sache die ich gerne noch verbessern würde währe die Bildübersicht. Ob es wohl irgendwie möglich ist die Bilder in zwei oder drei Spalten an zu ordnen?
-
hier noch die admin_pgp:
PHP
Alles anzeigen<?php //load configuration require("config.php"); //connect to database @mysql_connect($db_server,$db_user,$db_password) or die("Database server connection failed. Check variables \$db_server, \$db_user and \$db_password in config.php"); @mysql_select_db($db_name) or die("Selecting database failed. Check variable \$db_name in config.php"); //print header echo $header; //password $pw = $_GET['pw']; //simple login if($pw == $password){ $del = $_GET['del']; $res = $_GET['res']; //delete image if(isset($del)){ if(@unlink($img.$del.$img_format_info)){ @mysql_query("DELETE FROM $db_table_pictures WHERE id=$del;"); @mysql_query("DELETE FROM $db_table_comments WHERE id_pic=$del;"); ?><p>Image file, image information and comments have been deleted.</p><?php }else{ ?><p>Could not delete image file. Image information and comments have not been deleted.</p><?php } } //reset image if(isset($res)){ @mysql_query("UPDATE $db_table_pictures SET points=0,votes=0 WHERE id=$res;"); @mysql_query("DELETE FROM $db_table_comments WHERE id_pic=$res;"); ?><p>Points and votes have been reset.</p><?php } //print pages $s = isset($_GET['s']) ? $_GET['s'] : 0; $result = @mysql_query("SELECT * FROM $db_table_pictures WHERE id>1;"); for($i=0,$p=1;$i<@mysql_num_rows($result);$i=$i+$admin_show,$p++){ ?><a href="admin.php?pw=<?php echo $pw; ?>&s=<?php echo $i; ?>"><?php echo $p; ?></a> <?php } //print images ?><table border="0" cellpadding="0" cellspacing="15" width="<?php echo $img_width; ?>"><?php $result = @mysql_query("SELECT * FROM $db_table_pictures WHERE id>1 ORDER BY id ASC LIMIT $s,$admin_show;"); while($row=@mysql_fetch_array($result)){ $points = $row['votes'] ? number_format($row['points'] / $row['votes'],2,".","") : 0; ?> <tr> <td> <a href="index.php?show=<?php echo $row['id']; ?>"><img align="left" hspace="5" alt="" border="0" src="<?php echo $img.$row['id'].$img_format_info; ?>" width="100"></a> <b>Id:</b> <?php echo $row['id']; ?><br> <b>Name:</b> <?php echo $row['creator']; ?><br> <b>Comment:</b> <?php echo $row['comment']; ?><br> <b>Points:</b> <?php echo $row['points']; ?> (<?php echo $points; ?>)<br> <b>Votes:</b> <?php echo $row['votes']; ?> <br><br> <a href="admin.php?pw=<?php echo $pw; ?>&del=<?php echo $row['id']; ?>&s=<?php echo $s; ?>">Delete</a> | <a href="admin.php?pw=<?php echo $pw; ?>&res=<?php echo $row['id']; ?>&s=<?php echo $s; ?>">Reset</a> </td> </tr> <?php } ?></table><?php }else{ //print login form echo $login; } //print footer echo $footer; //close database connection @mysql_close(); ?>
Vielen Dank für eure mühe mit einem Anfänger wie mir Passte gar nicht alles in einen Beitrag.... -
Also irgendwie geht es immer noch nicht. Das hatte zwar wieder bewirkt das nicht abgestimmt werden kann, aber trotz das ich die Mindestvotes auf null gesetzt hatte mußte man mindestens ein mal voten damit die Bilder in der Liste erschienen was man dann natürlich nicht konnte.
Also hier mal das ganze Script:
index.php
PHP
Alles anzeigen<?php //load configuration require("config.php"); //connect to database @mysql_connect($db_server,$db_user,$db_password) or die("Database server connection failed. Check variables \$db_server, \$db_user and \$db_password in config.php"); @mysql_select_db($db_name) or die("Selecting database failed. Check variable \$db_name in config.php"); //update votes $id = $_POST['id']; $vote = $_POST['vote']; if(isset($id) && isset($vote)){ @mysql_query("UPDATE $db_table_pictures SET points=points+$vote,votes=votes+1 WHERE id=$id;"); } //store comment $comment_name = $_POST['comment_name']; $comment_text = $_POST['comment_text']; if(isset($comment_name) && isset($comment_text) && strlen($comment_name)>2 && strlen($comment_text)>2){ $comment_name = str_replace("<","<",$comment_name); $comment_name = str_replace(">",">",$comment_name); $comment_name = stripslashes($comment_name); $comment_text = str_replace("<","<",$comment_text); $comment_text = str_replace(">",">",$comment_text); $comment_text = stripslashes($comment_text); @mysql_query("INSERT INTO $db_table_comments (id_pic,name,text,date) VALUES({$_POST['show']},'$comment_name','$comment_text',".time().");"); } //image to be displayed if(!isset($_GET['show']) && !isset($_POST['show'])){ //random image $ids = array(); $result = @mysql_query("SELECT id FROM $db_table_pictures;"); list($min) = @mysql_fetch_row(@mysql_query("SELECT id FROM $db_table_pictures WHERE id>1 ORDER BY id ASC;")); list($max) = @mysql_fetch_row(@mysql_query("SELECT id FROM $db_table_pictures WHERE id>1 ORDER BY id DESC;")); while(list($ids[]) = @mysql_fetch_row($result)); while(true){ srand((double)microtime()*1000000); $show = rand($min,$max); if(array_search($show,$ids)){ break; } } }else{ //specific image $show = isset($_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;")); //calculate points if($row['points'] != 0){ $row['points'] = number_format($row['points']/$row['votes'],2,".",""); } //next image 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;")); } //print header echo $header; //print html ?><form action="index.php" method="post"> <table align="center" border="0" cellpadding="2" cellspacing="0"> <tr> <td rowspan="2">toll</td> <td rowspan="2" width="10"> </td><?php //voting form for($i=1;$i<=$max_points;$i++){ ?><td align="center"><?php echo $i; ?></td><?php } ?><td rowspan="2" width="10"> </td> <td rowspan="2">atemberaubend</td> </tr> <tr><?php for($i=1;$i<=$max_points;$i++){ ?><td align="center"><input type="radio" name="vote" value="<?php echo $i; ?>" onclick="submit();"></td><?php } ?></tr> </table> <input name="show" type="hidden" value="<?php echo $next; ?>"> <input name="id" type="hidden" value="<?php echo $row['id']; ?>"> </form> </td> </tr> <tr> <td colspan="2" height="8"> </td> </tr> <tr> <td align="center" colspan="2" height="<?php echo $img_height; ?>"><img alt="" border="0" src="<?php echo $img.$show.$img_format_info; ?>"></td> </tr> <tr> <td colspan="2" height="10"> </td> </tr> <tr> <td valign="top" width="50%">Image from <b><?php echo $row['creator']; ?></b><br><br><?php echo $row['comment']; ?><br><br></td> <td align="right" valign="top" width="50%">Points: <b><?php echo $row['points']; ?></b> (<?php echo $row['votes']; ?> votes)<br><br></td> </tr> <td colspan="2"> <hr><?php $result = @mysql_query("SELECT * FROM $db_table_comments WHERE id_pic={$row['id']} ORDER BY date DESC;"); if(@mysql_num_rows($result) == 0){ ?>Keine Kommentare<?php }else{ while($row = @mysql_fetch_array($result)){ ?><b><?php echo $row['name']; ?></b> schrieb am <?php echo date("m/d/Y",$row['date']); ?> um <?php echo date("h:i a",$row['date']); ?>:<br> <?php echo $row['text']; ?> <br><br><?php } } ?><hr> <b>Schreibe einen Kommentar:</b> <form action="index.php" method="post"> <table align="center" border="0" cellpadding="5" cellspacing="0"> <tr> <td>Dein 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,<?php echo $comment_size; ?>);" rows="6"></textarea></td> </tr> <tr> <td> </td> <td><input type="submit" value="senden"></td> </tr> </table> <input name="show" type="hidden" value="<?php echo $show; ?>"> </form><?php //print footer echo $footer; //close database connection @mysql_close(); ?>
config.php
PHP
Alles anzeigen<?php /* ######################## DATABASE ######################## */ // Database server $db_server = "localhost"; // Database name $db_name = "xxxxx_image"; // Database username $db_user = "xxxxxxmone"; // Database password $db_password = "xxxxx"; // Database table to store image information // (will be created automatically) $db_table_pictures = "image_voting_pictures"; // Database table to store the comments // (will be created automatically) $db_table_comments = "image_voting_comments"; /* ##################### CONFIGURATION ###################### */ // Complete URL of the script // (begins with http://, ends with slash) $url = "http://www.franzoesische-und-englische-bulldoggen-ev.de/Image_voting/"; // Relative path to the images folder // (folder where the images are stored). // Must be empty (then images are stored in the same folder // where the script is running) or relative with an ending // slash. // // Example 1 (Windows): // Script folder: C:\apache\htdocs\site\php\image_voting\ // Images folder: C:\apache\htdocs\site\img\upload\ // --> $img = "../../img/upload/"; // // Example 2 (Unix): // Script folder: /var/www/html/site/php/image_voting/ // Images folder: /var/www/html/site/img/upload/ // --> $img = "../../img/upload/"; // // The images folder must be writable! // (Windows: adjust security, Unix: chmod 777) $img = "./images/"; // Maximum length of comments (maximum 255) $comment_size = 255; // Maximum points for voting $max_points = 10; // Minimum votes for pictures to appear in toplist $min_votes = 0; // Maximum image width $img_width = 640; // Maximum image height $img_height = 480; // Image format // 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF $img_format = 2; // Maximum file size of images // 102400 = 100KB $img_size = 153600; // Email-address of administrator // (will be informed on new pictures $webmaster = "simone@franzoesische-und-englische-bulldoggen-ev.de"; // Administration password $password = "xxxx"; // Number of images to be shown on the administration page $admin_show = 10; // Title (will be displayed in the browser's header $title = "Image voting"; /* ######################### LAYOUT ######################### */ // Header to be used on each page $header = <<<EOT <!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=utf-8"> <link href="style.css" rel="stylesheet" type="text/css"> <title>$title</title> </head> <body> <table align="center" border="0" cellpadding="0" cellspacing="0" width="$img_width"> <tr> <td align="center" colspan="2"> <a href="index.php">Abstimmen!</a> | <a href="toplist.php">Liste</a> | <a href="create_new.php">Bild hochladen!</a> | <a href="admin.php">Administration</a> <hr> </td> </tr> <tr> <td align="center" colspan="2"> EOT; // Footer to be used on each page $footer = <<<EOT </td> </tr> </table> </body> </html> EOT; // Login form $login = <<<EOT <form action="admin.php" method="get"> Password: <input name="pw" type="password"> <input type="submit" value="Login"> </form> EOT; /* ############# SCRIPT (EDIT AT YOUR OWN RISK) ############# */ switch($img_format){ case 1: $img_format_info = ".gif"; break; case 2: $img_format_info = ".jpg"; break; case 3: $img_format_info = ".png"; break; case 4: $img_format_info = ".swf"; break; } ?>
create_new.php
PHP
Alles anzeigen<?php //load configuration require("config.php"); //connect to database @mysql_connect($db_server,$db_user,$db_password) or die("Database server connection failed. Check variables \$db_server, \$db_user and \$db_password in config.php"); @mysql_select_db($db_name) or die("Selecting database failed. Check variable \$db_name in config.php"); //print header echo $header; //print html ?><form action="create_new.php" enctype="multipart/form-data" method="post"> <table border="0" cellpadding="0" cellspacing="15" width="<?php echo $img_width; ?>"> <tr> <td colspan="2"><?php //upload image (form submitted) if(isset($_POST['submit'])){ $file = $_FILES['file']; $name = $_POST['name']; $email = $_POST['email']; $comment = $_POST['comment']; $error = false; $error_file = false; //check name if(strlen($name) < 3){ $name = "<b>At least three characters.</b>"; $error = true; } //check email if($email && !ereg('^[-^!#$%&\'*+\/=?`{|}~._a-z0-9]+@([-a-z0-9]+(\.[-a-z0-9]+)*\.[-a-z0-9]{2,6}|\[[0-9]{1,3}(\.[0-9]{1,3}){3}\])$',$email)){ $email = "<b>Must be valid.</b>"; $error = true; } //check file if($file == ""){ $file = "<b>No file chosen.</b>"; $error_file = true; $error = true; } //check comment if(strlen($comment) < 3){ $comment = "<b>At least three characters.</b>"; $error = true; } //file uploaded if(!$error_file){ $file_info = getimagesize($file['tmp_name']); $file_size = filesize($file['tmp_name']); //check image width if($file_info[0] > $img_width){ $message_width = "<b>{$file_info[0]} - image is ".($file_info[0] - $img_width)." pixels too broad.</b>"; $error = true; }else{ $message_width = $file_info[0]." pixels - ok"; } //check image height if($file_info[1] > $img_height){ $message_height = "<b>{$file_info[1]} - image is ".($file_info[1] - $img_height)." pixels too high.</b>"; $error = true; }else{ $message_height = $file_info[1]." pixels - ok"; } //check image format if($file_info[2] != $img_format){ $message_type = "<b>Image format must be $img_format_info.</b>"; $error = true; }else{ $message_type = $img_format_info." - ok"; } //check image size if($file_size > $img_size){ $message_size = "<b>".number_format($file_size/1024,0,",","")." - filesize is ".number_format(($file_size - $img_size) / 1024,0,",","")."KB too large.</b>"; $error = true; }else{ $message_size = number_format($file_size/1024,0,",","")."KB - ok"; } } ?> </td> </tr> <tr> <td>Name:</td> <td><?php echo $name; ?></td> </tr> <tr> <td>Email address:</td> <td><?php echo $email; ?></td> </tr> <tr> <td>Image:</td><?php //no error with image if(!$error_file){ ?><td> </td> </tr> <tr> <td> - Width:</td> <td><?php echo $message_width; ?></td> </tr> <tr> <td> - Height:</td> <td><?php echo $message_height; ?></td> </tr> <tr> <td> - Type:</td> <td><?php echo $message_type; ?></td> </tr> <tr> <td> - Size:</td> <td><?php echo $message_size; ?></td> </tr><?php //error with image }else{ ?><td><?php echo $file['name']; ?></td> </tr><?php } ?><tr> <td>Comment:</td> <td><?php echo $comment; ?></td> </tr><?php //error message $error_goback = <<<EOT <tr> <td align="center" colspan="2"> <br><br> <b>Dein Bild konnte leider nicht hochgeladen werden, bitte klicke <a href="javascript:history.back();">hier</a> um wieder zum Formular zu gelangen.</b> </td> </tr> EOT; //error occurred if($error){ echo $error_goback; //store image }else{ //get next id $row = @mysql_fetch_array(@mysql_query("SELECT id FROM $db_table_pictures ORDER BY id DESC LIMIT 0,1;")); $id = $row['id'] + 1; //copy image if(!(@copy($file['tmp_name'],$img.$id.$img_format_info))){ echo $error_goback; }else{ //insert into database @mysql_query("INSERT INTO $db_table_pictures VALUES('$id','$name','$comment',0,0);"); //send mail to user @mail($email,"Thank you for uploading your image at $title!","Your image has been uploaded successfully at $title!\n\nView image: {$url}index.php?show=$id\nView toplist: {$url}toplist.php\nVote for images: {$url}\nUpload another image: {$url}create_new.php","From: $webmaster <$webmaster>\n"); //send mail to administrator @mail($webmaster,"New image at $title","A new image has been uploaded at $title.\n\nName: $name\nEmail: $email\nComment: $comment\n\nView image: {$url}index.php?show=$id\nView toplist: {$url}toplist.php\nVote for images: {$url}\nUpload an image: {$url}create_new.php","From: $name <$email>\n"); ?><tr> <td align="center" colspan="2"> <br><br> <b>Dein Bild konnte erfolgreich hochgeladen werden! <a href="index.php?show=<?php echo $id; ?>">Klicke hier um fortzufahren.</a></b> </td> </tr><?php } } ?></table> </form><?php //print upload form }else{ ?>Lade hier ein Foto Deines Bullys hoch. <br><br> </td> </tr> <tr> <td>Dein Name:</td> <td><input maxlength="50" name="name" size="30" type="text"></td> </tr> <tr> <td>Deine E-mail Addresse:</td> <td><input name="email" size="30" type="text"></td> </tr> <tr> <td>Bild auswaehlen:</td> <td><input name="file" size="30" type="file"></td> </tr> <tr> <td valign="top">Kommentar:<br>(max. <?php echo $comment_size; ?> Zeichen)</td> <td><textarea cols="70" name="comment" onkeyup="this.value=this.value.slice(0,<?php echo $comment_size; ?>);" rows="6"></textarea></td> </tr> <tr> <td> </td> <td><input name="submit" type="submit" value="Hochladen"></td> <? echo "Bitte beachtet das Euer Bild nicht mehr als 150kb haben sollte und nicht mehr als 640x480px ist."; ?> </tr> </table> </form><?php } //print footer echo $footer; //close database connection @mysql_close(); ?>
toplist.php
PHP
Alles anzeigen<?php //load configuration require("config.php"); //connect to database @mysql_connect($db_server,$db_user,$db_password) or die("Database server connection failed. Check variables \$db_server, \$db_user and \$db_password in config.php"); @mysql_select_db($db_name) or die("Selecting database failed. Check variable \$db_name in config.php"); //number of images $count = @mysql_num_rows(@mysql_query("SELECT id FROM $db_table_pictures WHERE id>1 && votes>=$min_votes;")); $show = $_POST['show'] ? $_POST['show'] : 10; $show = $show > $count ? $count : $show; $result = @mysql_query("SELECT id,creator,comment,votes,points,points/votes as avg FROM $db_table_pictures WHERE id>1 && votes>=$min_votes && votes>0 ORDER BY avg DESC LIMIT 0,$show;"); //print header echo $header; //print html ?><form action="toplist.php" method="post"> <table bgcolor="#efefef" border="0" cellpadding="5" cellspacing="5" width="<?php echo $img_width; ?>"> <tr> <td align="center"> Liste <select name="show"><?php //select toplist for($i=10;$i<$count;$i+=10){ ?><option value="<?php echo $i; ?>"><?php echo $i; ?></option><?php } ?><option value="<?php echo $count; ?>">all</option> </select> <input type="submit" value="ok"> <br>(mindestens <?php echo $min_votes; ?> Stimme) </td> </tr> </table> </form> <table border="0" cellpadding="0" cellspacing="15" width="<?php echo $img_width; ?>"><?php //display images for($r=1;$row=mysql_fetch_array($result);$r++){ $points = $row['votes'] ? number_format($row['points'] / $row['votes'],2,".","") : 0; ?><tr> <td> <a href="index.php?show=<?php echo $row['id']; ?>"><img align="left" hspace="5" alt="" border="0" height="100" src="<?php echo $img.$row['id'].$img_format_info; ?>" width="100"></a> <b>Rank <?php echo $r; ?></b> <br><br> total: <?php echo $points; ?> (<?php echo $row['votes']; ?> votes) <br><br> <b><?php echo $row['creator']; ?></b><br> <?php echo $row['comment']; ?> </td> </tr><?php } ?></table><?php //no images in toplist if($count == 0){ ?><br><br>No images in toplist.<?php } //print footer echo $footer; //close database connection @mysql_close(); ?>
-
nein...leider....ich hab es jetzt wieder in den Originalzustand gesetzt.....
Das Problem scheint zu sein das irgendwo vorausgesetzt wird das mindestens einmal auf ein Bild gevotet wird, bevor es in die Topliste die ja eigentlich die meist gevoteten Bilder nach oben setzt erscheint.
Scheint echt schwierig zu sein....ich möchte doch einfach nur ein Script in dem die User Bilder hochladen können und die dann angezeigt werden...:(
Trotzdem vielen Dank für deine Mühe und Hilfe....bin jedenfalls etwas schlauer geworden.
Vielleicht findet sich ja doch noch eine Lösung.
-
Ok...ich guck nochmal was ich falsch gemacht habe.
-
Nein...:( leider bringt das auch nix.....
ist die Lösung vielleicht in der config.php zu finden?
PHP
Alles anzeigen<?php /* ######################## DATABASE ######################## */ // Database server $db_server = "localhost"; // Database name $db_name = "xxxximage"; // Database username $db_user = "xxxxxmone"; // Database password $db_password = "xxxx"; // Database table to store image information // (will be created automatically) $db_table_pictures = "image_voting_pictures"; // Database table to store the comments // (will be created automatically) $db_table_comments = "image_voting_comments"; /* ##################### CONFIGURATION ###################### */ // Complete URL of the script // (begins with http://, ends with slash) $url = "http://www.franzoesische-und-englische-bulldoggen-ev.de/Image_voting/"; // Relative path to the images folder // (folder where the images are stored). // Must be empty (then images are stored in the same folder // where the script is running) or relative with an ending // slash. // // Example 1 (Windows): // Script folder: C:\apache\htdocs\site\php\image_voting\ // Images folder: C:\apache\htdocs\site\img\upload\ // --> $img = "../../img/upload/"; // // Example 2 (Unix): // Script folder: /var/www/html/site/php/image_voting/ // Images folder: /var/www/html/site/img/upload/ // --> $img = "../../img/upload/"; // // The images folder must be writable! // (Windows: adjust security, Unix: chmod 777) $img = "./images/"; // Maximum length of comments (maximum 255) $comment_size = 255; // Maximum points for voting $max_points = 10; // Minimum votes for pictures to appear in toplist $min_votes = 0; // Maximum image width $img_width = 640; // Maximum image height $img_height = 480; // Image format // 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF $img_format = 2; // Maximum file size of images // 102400 = 100KB $img_size = 153600; // Email-address of administrator // (will be informed on new pictures $webmaster = "simone@franzoesische-und-englische-bulldoggen-ev.de"; // Administration password $password = "xxxxx"; // Number of images to be shown on the administration page $admin_show = 10; // Title (will be displayed in the browser's header $title = "Image voting"; /* ######################### LAYOUT ######################### */ // Header to be used on each page $header = <<<EOT <!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=utf-8"> <link href="style.css" rel="stylesheet" type="text/css"> <title>$title</title> </head> <body> <table align="center" border="0" cellpadding="0" cellspacing="0" width="$img_width"> <tr> <td align="center" colspan="2"> <a href="index.php">Abstimmen!</a> | <a href="toplist.php">Liste</a> | <a href="create_new.php">Bild hochladen!</a> | <a href="admin.php">Administration</a> <hr> </td> </tr> <tr> <td align="center" colspan="2"> EOT; // Footer to be used on each page $footer = <<<EOT </td> </tr> </table> </body> </html> EOT; // Login form $login = <<<EOT <form action="admin.php" method="get"> Password: <input name="pw" type="password"> <input type="submit" value="Login"> </form> EOT; /* ############# SCRIPT (EDIT AT YOUR OWN RISK) ############# */ switch($img_format){ case 1: $img_format_info = ".gif"; break; case 2: $img_format_info = ".jpg"; break; case 3: $img_format_info = ".png"; break; case 4: $img_format_info = ".swf"; break; } ?>
Hochgeladen sind die Bilder jedenfalls, denn im Adminmenue kann ich sie sehen.
-
Danke....das hat schon mal geklappt.....leider erschienen die hochgeladenen Bilder jetzt aber nicht mehr in der Liste.....weil die bezieht sich wohl irgendwie auf die Voteings......
Mh.....hier mal der php der Liste vielleicht kannst du damit was anfangn!
PHP
Alles anzeigen<?php //load configuration require("config.php"); //connect to database @mysql_connect($db_server,$db_user,$db_password) or die("Database server connection failed. Check variables \$db_server, \$db_user and \$db_password in config.php"); @mysql_select_db($db_name) or die("Selecting database failed. Check variable \$db_name in config.php"); //number of images $count = @mysql_num_rows(@mysql_query("SELECT id FROM $db_table_pictures WHERE id>1 && votes>=$min_votes;")); $show = $_POST['show'] ? $_POST['show'] : 10; $show = $show > $count ? $count : $show; $result = @mysql_query("SELECT id,creator,comment,votes,points,points/votes as avg FROM $db_table_pictures WHERE id>1 && votes>=$min_votes && votes>0 ORDER BY avg DESC LIMIT 0,$show;"); //print header echo $header; //print html ?><form action="toplist.php" method="post"> <table bgcolor="#efefef" border="0" cellpadding="5" cellspacing="5" width="<?php echo $img_width; ?>"> <tr> <td align="center"> Liste <select name="show"><?php //select toplist for($i=10;$i<$count;$i+=10){ ?><option value="<?php echo $i; ?>"><?php echo $i; ?></option><?php } ?><option value="<?php echo $count; ?>">all</option> </select> <input type="submit" value="ok"> <br>(mindestens <?php echo $min_votes; ?> Stimme) </td> </tr> </table> </form> <table border="0" cellpadding="0" cellspacing="15" width="<?php echo $img_width; ?>"><?php //display images for($r=1;$row=mysql_fetch_array($result);$r++){ $points = $row['votes'] ? number_format($row['points'] / $row['votes'],2,".","") : 0; ?><tr> <td> <a href="index.php?show=<?php echo $row['id']; ?>"><img align="left" hspace="5" alt="" border="0" height="100" src="<?php echo $img.$row['id'].$img_format_info; ?>" width="100"></a> <b>Rank <?php echo $r; ?></b> <br><br> total: <?php echo $points; ?> (<?php echo $row['votes']; ?> votes) <br><br> <b><?php echo $row['creator']; ?></b><br> <?php echo $row['comment']; ?> </td> </tr><?php } ?></table><?php //no images in toplist if($count == 0){ ?><br><br>No images in toplist.<?php } //print footer echo $footer; //close database connection @mysql_close(); ?>
In der config php hatte ich schon angegeben das ein Bild 0 Votes braucht um in der Liste zu erscheinen aber das nützt nix.....
-
Du hast recht, das traue ich mir nicht zu.....
Die index.php sieht so aus:
PHP
Alles anzeigen<?php //load configuration require("config.php"); //connect to database @mysql_connect($db_server,$db_user,$db_password) or die("Database server connection failed. Check variables \$db_server, \$db_user and \$db_password in config.php"); @mysql_select_db($db_name) or die("Selecting database failed. Check variable \$db_name in config.php"); //update votes $id = $_POST['id']; $vote = $_POST['vote']; if(isset($id) && isset($vote)){ @mysql_query("UPDATE $db_table_pictures SET points=points+$vote,votes=votes+1 WHERE id=$id;"); } //store comment $comment_name = $_POST['comment_name']; $comment_text = $_POST['comment_text']; if(isset($comment_name) && isset($comment_text) && strlen($comment_name)>2 && strlen($comment_text)>2){ $comment_name = str_replace("<","<",$comment_name); $comment_name = str_replace(">",">",$comment_name); $comment_name = stripslashes($comment_name); $comment_text = str_replace("<","<",$comment_text); $comment_text = str_replace(">",">",$comment_text); $comment_text = stripslashes($comment_text); @mysql_query("INSERT INTO $db_table_comments (id_pic,name,text,date) VALUES({$_POST['show']},'$comment_name','$comment_text',".time().");"); } //image to be displayed if(!isset($_GET['show']) && !isset($_POST['show'])){ //random image $ids = array(); $result = @mysql_query("SELECT id FROM $db_table_pictures;"); list($min) = @mysql_fetch_row(@mysql_query("SELECT id FROM $db_table_pictures WHERE id>1 ORDER BY id ASC;")); list($max) = @mysql_fetch_row(@mysql_query("SELECT id FROM $db_table_pictures WHERE id>1 ORDER BY id DESC;")); while(list($ids[]) = @mysql_fetch_row($result)); while(true){ srand((double)microtime()*1000000); $show = rand($min,$max); if(array_search($show,$ids)){ break; } } }else{ //specific image $show = isset($_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;")); //calculate points if($row['points'] != 0){ $row['points'] = number_format($row['points']/$row['votes'],2,".",""); } //next image 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;")); } //print header echo $header; //print html ?><form action="index.php" method="post"> <table align="center" border="0" cellpadding="2" cellspacing="0"> <tr> <td rowspan="2">toll</td> <td rowspan="2" width="10"> </td><?php //voting form for($i=1;$i<=$max_points;$i++){ ?><td align="center"><?php echo $i; ?></td><?php } ?><td rowspan="2" width="10"> </td> <td rowspan="2">atemberaubend</td> </tr> <tr><?php for($i=1;$i<=$max_points;$i++){ ?><td align="center"><input type="radio" name="vote" value="<?php echo $i; ?>" onclick="submit();"></td><?php } ?></tr> </table> <input name="show" type="hidden" value="<?php echo $next; ?>"> <input name="id" type="hidden" value="<?php echo $row['id']; ?>"> </form> </td> </tr> <tr> <td colspan="2" height="8"> </td> </tr> <tr> <td align="center" colspan="2" height="<?php echo $img_height; ?>"><img alt="" border="0" src="<?php echo $img.$show.$img_format_info; ?>"></td> </tr> <tr> <td colspan="2" height="10"> </td> </tr> <tr> <td valign="top" width="50%">Image from <b><?php echo $row['creator']; ?></b><br><br><?php echo $row['comment']; ?><br><br></td> <td align="right" valign="top" width="50%">Points: <b><?php echo $row['points']; ?></b> (<?php echo $row['votes']; ?> votes)<br><br></td> </tr> <td colspan="2"> <hr><?php $result = @mysql_query("SELECT * FROM $db_table_comments WHERE id_pic={$row['id']} ORDER BY date DESC;"); if(@mysql_num_rows($result) == 0){ ?>Keine Kommentare<?php }else{ while($row = @mysql_fetch_array($result)){ ?><b><?php echo $row['name']; ?></b> schrieb am <?php echo date("m/d/Y",$row['date']); ?> um <?php echo date("h:i a",$row['date']); ?>:<br> <?php echo $row['text']; ?> <br><br><?php } } ?><hr> <b>Schreibe einen Kommentar:</b> <form action="index.php" method="post"> <table align="center" border="0" cellpadding="5" cellspacing="0"> <tr> <td>Dein 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,<?php echo $comment_size; ?>);" rows="6"></textarea></td> </tr> <tr> <td> </td> <td><input type="submit" value="senden"></td> </tr> </table> <input name="show" type="hidden" value="<?php echo $show; ?>"> </form><?php //print footer echo $footer; //close database connection @mysql_close(); ?>
-
Hallo, ich habe auf der HP unseres Vereins ein Fotoalbum angelegt bei dem User ihre Bilder hochladen kommentieren und bewerten lassen können.....
Das ganze könnt ihr hier mal sehen: http://www.franzoesische-und-englische-bulldoggen-ev.de/Image_voting/
Nun finden einige unsere Mitglieder aber die Vote Funktion nicht so toll.....könnte ich das Script dahin gehend verändern? Oder kennt ihr ein anderes?
Ich bin leider echt kein Profi leider.......:-(