Eurokicker
-


Hinweise


Antwort
 
LinkBack Themen-Optionen Thema durchsuchen Thema bewerten
Alt 02.01.2006, 21:41   #1
mmm
TP-Member
 
Registriert seit: Jul 2003
mmm macht alles soweit korrekt

Bewertungsscript mit Stars - Image Voting


Hallo,

ich habe folgendes Bewertungsscript 'gefunden':

PHP-Code:
<?
$path
"http://www.luogo.de/test";
$ficdest=explode(".",basename($PHP_SELF));
$ficdest=$ficdest[0].".dat";

if(
file_exists($ficdest)) {
     
$compteur=fopen($ficdest"r");
     
$old_stats=file($ficdest);
     
$stats=explode("|"$old_stats[0]);
     
fclose($compteur);
     
$new_count=$stats[0];
     if (
$stats[3] != $REMOTE_ADDR) {
         
$new_count +=1;
     }
     
$ip_hit=$REMOTE_ADDR;
     
$compteur=fopen($ficdest"w");
     
fputs($compteur"$new_count|$stats[1]|$stats[2]|$ip_hit|$stats[4]");
     
fclose($compteur);
}
else {
     
$nouveau_compteur=fopen($ficdest"w");
     
fputs($nouveau_compteur"1|||$REMOTE_ADDR|");
     
fclose($nouveau_compteur);
}

if (!empty(
$envoi)) {
     
$vote=fopen($ficdest"r");
     
$old_stats=file($ficdest);
     
$stats=explode("|"$old_stats[0]);
     
fclose($vote);
     
$nbr_votes=$stats[1];
     
$moy_votes=$stats[2];
     if (
$stats[4] != $REMOTE_ADDR) {
         
$nbr_votes +=1;
         
$moy_votes=((($stats[1]*$stats[2])+$note)/$nbr_votes);
     }
else { echo 
"<font face=Verdana size=2 color=red>Sie haben schon abgestimmt</font>"; }
     
$ip_vote=$REMOTE_ADDR;
     
$vote=fopen($ficdest"w");
     
$new_stats=fputs($vote"$new_count|$nbr_votes|$moy_votes|$stats[3]|$ip_vote");
     
fclose($vote);
}

print (
"<form method=post>");
$old_stats=file($ficdest);
$stats=explode("|"$old_stats[0]);
if (
$stats[2]>=5)
{
    
$star "$path/images/5star.gif" ;
}
if (
$stats[2]<=4.5)
{
    
$star "$path/images/45star.gif" ;
}
if (
$stats[2]<=4)
{
    
$star "$path/images/4star.gif" ;
}
if (
$stats[2]<=3.5)
{
    
$star "$path/images/35star.gif" ;
}
if (
$stats[2]<=3)
{
    
$star "$path/images/3star.gif" ;
}
if (
$stats[2]<=2.5)
{
    
$star "$path/images/25star.gif" ;
}
if (
$stats[2]<=2)
{
    
$star "$path/images/2star.gif" ;
}
if (
$stats[2]<=1.5)
{
    
$star "$path/images/15star.gif" ;
}
if (
$stats[2]<=1)
{
    
$star "$path/images/1star.gif" ;
}
if (
$stats[2]<=0.5)
{
    
$star "$path/images/05star.gif" ;
}
if (
$stats[2]<=0)
{
    
$star "$path/images/00star.gif" ;
}
print (
"<font size=1 face=Verdana color=#999999>Bewertung: <img src=\"$star\" alt=\"Durchschnittliche Bewertung: $stats[2]\">&nbsp; $stats[1] Bewertung(en)</font>");
print (
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<select name=note>");
for (
$i=1$i<=5$i++) {
print (
"<option value=$i>$i");
}
print (
"&nbsp;&nbsp;</select> <input type=hidden name=envoi value=1><input type=submit value=Rate>");
print (
"</form></font>");
?>
Funktioniert auch soweit - möchte nun anstatt des Auswahlmenüs eine Grafik / Liste benutzen in form von:

PHP-Code:
<ul class='star-rating'>
  <
li><a href='#1' title='Rate this 1 star out of 5' class='one-star'>1</a></li>
  <
li><a href='#2' title='Rate this 2 stars out of 5' class='two-stars'>2</a></li>
  <
li><a href='#3' title='Rate this 3 stars out of 5' class='three-stars'>3</a></li>
  <
li><a href='#4' title='Rate this 4 stars out of 5' class='four-stars'>4</a></li>
  <
li><a href='#5' title='Rate this 5 stars out of 5' class='five-stars'>5</a></li>
</
ul>

Ist dies machbarStehe irgendwie komplett auf dem SchlauchMan müsste dann ja jede <ials Button definieren

Danke & Gruß

ach: Online Bsp.: http://luogo.de/test/rate.php
mmm ist offline   Mit Zitat antworten


Alt 02.01.2006, 23:14   #2
TP-Specialist
 
Benutzerbild von rewboss
 
Registriert seit: Mar 2005
Ort: Unterfranken
rewboss ist ein richtiges Arbeitstier - DANKErewboss ist ein richtiges Arbeitstier - DANKErewboss ist ein richtiges Arbeitstier - DANKErewboss ist ein richtiges Arbeitstier - DANKErewboss ist ein richtiges Arbeitstier - DANKErewboss ist ein richtiges Arbeitstier - DANKE
Ja. Du musst nur die Variablen in die URLs schreiben, die in der Vorlage vom Formular aus versandt werden.

Wenn ich den Code richtig verstanden habe, musst du zwei Variablen übergeben: envoi (französisch für "abgeschickt") und note. Und so müsste es aussehen:

Code:
<a href="/datei.php?envoi=1&amp;note=1" title="Rate this 1 star out of 5"...
...also so:

PHP-Code:
for($i=1$i<=5$i++){
 print(
"<li><a href=\"".$_SERVER['PHP_SELF']."?envoi=1&amp;note=$i\"
          title=\"Rate this $i star"
.($i==1?"":"s")." out of 5\">$i</a>");

rewboss ist offline   Mit Zitat antworten
Alt 03.01.2006, 19:57   #3
mmm
TP-Member
 
Registriert seit: Jul 2003
mmm macht alles soweit korrekt
Herzlichen Dank - es funktioniert!
mmm ist offline   Mit Zitat antworten
Antwort

  Aktuelles Thema
  TP Hilfe Forum > Web-Editoren & Coding > Traum-Dynamik
Bewertungsscript mit Stars - Image Voting Bewertungsscript mit Stars - Image Voting
« adresstabelle durchgehen und automatische mail verschicken ? | form (button) method POST aber als link? »

Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
 
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Thema bewerten
Thema bewerten:

Forumregeln
Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are an
Gehe zu


Alle Zeitangaben in WEZ +2. Es ist jetzt 19:51 Uhr.

Powered by: vBulletin Version 3.7 (Deutsch)
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd. / Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.
Traum-Projekt.com | Suchen | Archiv | Impressum | Kontakt | | | Nach oben |



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67