muga: Vote-box

Beitrag lesen

Danke für die ausführliche Antwort vorallem von Auge.

ich habe den Code bis hier geschaft, aber trotzdem zählt er hoch beim Drucken von F5 weiter. es wäre werklich sehr nett, wenn jemand mir die stelle, wo es noch was fiehlt klären

<?
global $action;
global $Wahl;
//global $msub_Comp_ID;
global $Vote_System2;
//include("../mysqlconnect.php");
//$Owner_ID=1;
//global $Vote_System;
//$msub_Comp_ID=6;
?>
<?
//$add_to.="Nr:  $Vote_System2";
//echo "nr: ".$Vote_System;

if(!isset($msub_Comp_ID) or $msub_Comp_ID==0)
{
$add_to.="Fehler in der Votebox!";
}
else
{

if($Vote_System2==$msub_Comp_ID)
{
//setcookie("Vote_System","sd",time()+12*3600);
$add_to.= "Heute schon gevotet. Erst in 24 Stunden wieder!";
$showvote=1;
}

?>
<?
//ab hier kann das Fehler liegen
if(!isset($action) and !isset($showvote))
{
$sql="SELECT * FROM voting_frage where frage_ID=$msub_Comp_ID";

	if(!$ergebnis=mysql\_query($sql))  

{
  $add_to.= mysql_errno()." : ".mysql_error();
 
  }

	while($entry=mysql\_fetch\_object($ergebnis,MYSQL\_ASSOC))  

{
  // die Umfrage klingt deutlicher in einer Tabelle
 
$add_to.= "<table style='background-color:#0000FF' border ='0' width='100%' height='100%'><tr><td align=left>". "<b style ='color:#FFFFFF'>".$entry->Frage."</b>"."</td></tr>";
}

	$sql="SELECT \* FROM voting\_antworten where frage\_ID=$msub\_Comp\_ID";  
  
	  
	  
	if(!$ergebnis=mysql\_query($sql))  

{
  $add_to.= mysql_errno()." : ".mysql_error();
  exit();
  }
  $add_to.="<b style ='color:#FF0000'> Unsere aktulle Umfrage für Sie!! </b>";
$add_to.= "<form method=get action=''>";

	while($entry=mysql\_fetch\_object($ergebnis,MYSQL\_ASSOC))  

{
   //$Antwort = $entry->Antwort;
$add_to.= "<table style='background-color:#0000FF' border ='0' width='100%'><tr><td align=left><input type=radio name=Wahl value='$entry->Ant_ID'></td><td style ='color:#FFFFFF' align=left >$entry->Antwort</td></tr>";

//setcookie("Ant",$entry->Antwort,time()+5);
    }

	$add\_to.= "<tr><td><input type=hidden name=action value=add>&nbsp;&nbsp;</td><td><input type=submit value=OK></td></tr>";  
	$add\_to.= "</table><input type=hidden name=level value=$level><input type=hidden name=Top\_ID value=$Top\_ID><input type=hidden name=ID value=$ID></form>";  

}
else if($action=="add")
{
// die Wahl darf nciht mehr als 3 Sekunden gewählt
// if (isset($Wahl) or $Wahl!="") { setcookie("wahl",$Wahl,time()+5);}
if(!isset($Wahl) or $Wahl=="")
{

$add_to.="Sie haben nichts ausgewählt.<a href='javascript:history.back();'>Zurück</a>";
}
else
{

$sql="SELECT Ergebnis FROM voting_antworten where Ant_ID=$Wahl";

	if(!$ergebnis=mysql\_query($sql))  

{
  $add_to.= mysql_errno()." : ".mysql_error();
 
  }

	$wert=1;  
		if($entry=mysql\_fetch\_object($ergebnis,MYSQL\_ASSOC))  
		{  
		$wert=$wert+$entry->Ergebnis;	  
		}  

//ab hier besser aufpassen
$sql="Update voting_antworten Set Ergebnis=$wert where Ant_ID=$Wahl";

	if(!$ergebnis=mysql\_query($sql))  

{
  $add_to.= mysql_errno()." : ".mysql_error();
  }

			//setcookie("Vote\_System",$msub\_Comp\_ID,time()+5);  
	$Vote\_System2=$msub\_Comp\_ID;  
			//$add\_to.= $Vote\_System;  

$add_to.= "<table style='background-color:#0000FF' border ='0' width='100%' height='100%'><tr><td align=left>". "<b style ='color:#FFFFFF'>" ."Sie haben Ihre Stimme abgegeben!</b>"."</td></tr>";

$showvote=1;

}
}
if(isset($showvote) and $showvote==1)
{

	$sql="SELECT \* FROM voting\_antworten where frage\_ID=$msub\_Comp\_ID";  
  
	if(!$ergebnis=mysql\_query($sql))  

{
  $add_to.= mysql_errno()." : ".mysql_error();
  }

	$total=0;  
	while($entry=mysql\_fetch\_object($ergebnis,MYSQL\_ASSOC))  

{
$total=$total+$entry->Ergebnis;
}

	$sql="SELECT \* FROM voting\_antworten where frage\_ID=$msub\_Comp\_ID";  
  
	if(!$ergebnis=mysql\_query($sql))  

{
  $add_to.= mysql_errno()." : ".mysql_error();
  exit();
  }

	$anz\_ant=0;  
	//$total=mysql\_num\_rows($ergebnis);  
	$add\_to.= "<br>";  
	  
			if($total==0) $total=1;  
	  
	while($entry=mysql\_fetch\_object($ergebnis,MYSQL\_ASSOC))  

{
$anz_ant++;
$pro_erg=100*$entry->Ergebnis/$total;
$pro_erg=round($pro_erg);

	$pro\_erg\_gr=(int) ($pro\_erg/2);  
	$add\_to.= "<table width=100%><tr><td width=50 align='left'><img src='http://www.saarsportvereine.de/content\_01/systemdesign/vote\_farb\_".(($anz\_ant % 5)+1).".jpg' width='$pro\_erg\_gr' height='15'></td><td width=40 align='left'>$entry->Antwort &nbsp;</td><td width=10>".$pro\_erg."% ($entry->Ergebnis)</td></tr></table>";  

}
   $add_to.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type='submit'  name='zurueck' value='zurück' OnClick='javascript:history.back();'>";

}
}

schöne Grüße

muga