04. november 2003 - 02:08
Der er
11 kommentarer og 1 løsning
mysql problem med vote
jeg vil gerne have en afstemning på min site men jeg kan ikke resutatet der er bare en blank side.
jeg skulle mene at jeg har lavet det rigtigt men ... ?
www.2kokke.dk/p/form.php har er linket så du/i kan prøve jeg kan godt sende koderne hvis det er en nødventighed.
Annonceindlæg fra HP
04. november 2003 - 02:09
#1
Not Found The requested URL /p/form.php was not found on this server.
04. november 2003 - 02:10
#2
nu kan jeg se den, læg lige koden...
04. november 2003 - 02:10
#3
prøv igen er lige opdateret
04. november 2003 - 02:11
#4
hvilke en af dem?
04. november 2003 - 02:11
#5
vote.php og form.php
04. november 2003 - 02:12
#6
dette er vote.php <? if ($side == "afstemning") { ?> <b><font size="2" face="verdana">Afstemning</font></b> <br><br> <? include "db_conn.php"; include "vars.php"; $var = $_POST['var']; mysql_query("insert into vote (var) values ($var)"); $sql = mysql_query("Select count(*) as antal from vote"); $sam = mysql_fetch_array($sql); $sql = mysql_query("Select count(*) as antal from vote where var = '1'"); $vote1 = mysql_fetch_array($sql); $sql = mysql_query("Select count(*) as antal from vote where var = '2'"); $vote2 = mysql_fetch_array($sql); $sql = mysql_query("Select count(*) as antal from vote where var = '3'"); $vote3 = mysql_fetch_array($sql); $sql = mysql_query("Select count(*) as antal from vote where var = '4'"); $vote4 = mysql_fetch_array($sql); $sql = mysql_query("Select count(*) as antal from vote where var = '5'"); $vote5 = mysql_fetch_array($sql); $res1 = ($vote1['antal'] / ($sam['antal'] / 100)) * 3; $res2 = ($vote2['antal'] / ($sam['antal'] / 100)) * 3; $res3 = ($vote3['antal'] / ($sam['antal'] / 100)) * 3; $res4 = ($vote4['antal'] / ($sam['antal'] / 100)) * 3; $res5 = ($vote5['antal'] / ($sam['antal'] / 100)) * 3; $ress1 = round(($res1 / 3), 2); $ress2 = round(($res2 / 3), 2); $ress3 = round(($res3 / 3), 2); $ress4 = round(($res4 / 3), 2); $ress5 = round(($res5 / 3), 2); $samlet = $sam['antal']; $antal1 = $vote1['antal']; $antal2 = $vote2['antal']; $antal3 = $vote3['antal']; $antal4 = $vote4['antal']; $antal5 = $vote5['antal']; $html = "<font size=\"1\" face=\"verdana\">$emne<br><br>Stemmer i alt: $samlet <br>"; $html .= "<br><table height=\"10\" width=\"$res1\" bgcolor=\"#FF0000\"> <br></table> $ress1 % ($antal1 Stemmer)<br>"; $html .= "<b>$valg1</b><br><table height=\"10\" width=\"$res2\" bgcolor=\"#FF0000\"> <br></table> $ress2 % ($antal2 Stemmer)<br>"; $html .= "<b>$valg2</b><br><table height=\"10\" width=\"$res3\" bgcolor=\"#FF0000\"> <br></table> $ress3 % ($antal3 Stemmer)<br>"; $html .= "<b>$valg3</b><br><table height=\"10\" width=\"$res4\" bgcolor=\"#FF0000\"> <br></table> $ress4 % ($antal4 Stemmer)<br>"; $html .= "<b>$valg4</b><br><table height=\"10\" width=\"$res5\" bgcolor=\"#FF0000\"> <br></table> $ress5 % ($antal5 Stemmer)<br><b>$valg5</b>"; echo $html; } elseif ($side == "resultat") { ?> <b><font size="2" face="verdana">Xyz3D.dk > Afstemning</font></b> <br><br> <? include "db_conn.php"; include "vars.php"; $sql = mysql_query("Select count(*) as antal from vote"); $sam = mysql_fetch_array($sql); $sql = mysql_query("Select count(*) as antal from vote where var = '1'"); $vote1 = mysql_fetch_array($sql); $sql = mysql_query("Select count(*) as antal from vote where var = '2'"); $vote2 = mysql_fetch_array($sql); $sql = mysql_query("Select count(*) as antal from vote where var = '3'"); $vote3 = mysql_fetch_array($sql); $sql = mysql_query("Select count(*) as antal from vote where var = '4'"); $vote4 = mysql_fetch_array($sql); $sql = mysql_query("Select count(*) as antal from vote where var = '5'"); $vote5 = mysql_fetch_array($sql); $res1 = ($vote1['antal'] / ($sam['antal'] / 100)) * 3; $res2 = ($vote2['antal'] / ($sam['antal'] / 100)) * 3; $res3 = ($vote3['antal'] / ($sam['antal'] / 100)) * 3; $res4 = ($vote4['antal'] / ($sam['antal'] / 100)) * 3; $res5 = ($vote5['antal'] / ($sam['antal'] / 100)) * 3; $ress1 = round(($res1 / 3), 2); $ress2 = round(($res2 / 3), 2); $ress3 = round(($res3 / 3), 2); $ress4 = round(($res4 / 3), 2); $ress5 = round(($res5 / 3), 2); $samlet = $sam['antal']; $antal1 = $vote1['antal']; $antal2 = $vote2['antal']; $antal3 = $vote3['antal']; $antal4 = $vote4['antal']; $antal5 = $vote5['antal']; $html = "<font size=\"1\" face=\"verdana\">$emne<br><br>Stemmer i alt: $samlet <br>"; $html .= "<br><table height=\"10\" width=\"$res1\" bgcolor=\"#FF0000\"> <br></table> $ress1 % ($antal1 Stemmer)<br>"; $html .= "<b>$valg1</b><br><table height=\"10\" width=\"$res2\" bgcolor=\"#FF0000\"> <br></table> $ress2 % ($antal2 Stemmer)<br>"; $html .= "<b>$valg2</b><br><table height=\"10\" width=\"$res3\" bgcolor=\"#FF0000\"> <br></table> $ress3 % ($antal3 Stemmer)<br>"; $html .= "<b>$valg3</b><br><table height=\"10\" width=\"$res4\" bgcolor=\"#FF0000\"> <br></table> $ress4 % ($antal4 Stemmer)<br>"; $html .= "<b>$valg4</b><br><table height=\"10\" width=\"$res5\" bgcolor=\"#FF0000\"> <br></table> $ress5 % ($antal5 Stemmer)<br><b>$valg5</b>"; echo $html; } ?>
04. november 2003 - 02:13
#7
dette er form.php <form method="post" action="vote.php?side=afstemning"> <span class="style1"><? include "vars.php"; echo $emne; ?></span><br> <input name="var" type="radio" value="1"> <span class="style3"><? echo $valg1; ?></span><br> <input name="var" type="radio" value="2"> <span class="style3"><? echo $valg2; ?></span><br> <input name="var" type="radio" value="3"> <span class="style3"><? echo $valg3; ?></span><br> <input name="var" type="radio" value="4"> <span class="style3"><? echo $valg4; ?></span><br> <input name="var" type="radio" value="5"> <span class="style3"><? echo $valg5; ?></span><br> <input name="Stem" type="submit" class="style3" id="Stem" value="Stem"> <a href="vote.php?side=resultat"><span class="style1">Se Resultat </span></a><span class="style1"> </span> </form>
04. november 2003 - 02:25
#8
kig lidt på det og jeg håber du kan hjælpe jeg vender tilbage imorgen jeg bliver nød til at hoppe i kanen jeg skal jobbe imorgen !!!
04. november 2003 - 02:42
#9
prøv lige <? if ($_GET["side"] == "afstemning") { ?> <b><font size="2" face="verdana">Afstemning</font></b> <br><br> <? include "db_conn.php"; include "vars.php"; $var = $_POST['var']; mysql_query("insert into vote (var) values ($var)"); $sql = mysql_query("Select count(*) as antal from vote"); $sam = mysql_fetch_array($sql); $sql = mysql_query("Select count(*) as antal from vote where var = '1'"); $vote1 = mysql_fetch_array($sql); $sql = mysql_query("Select count(*) as antal from vote where var = '2'"); $vote2 = mysql_fetch_array($sql); $sql = mysql_query("Select count(*) as antal from vote where var = '3'"); $vote3 = mysql_fetch_array($sql); $sql = mysql_query("Select count(*) as antal from vote where var = '4'"); $vote4 = mysql_fetch_array($sql); $sql = mysql_query("Select count(*) as antal from vote where var = '5'"); $vote5 = mysql_fetch_array($sql); $res1 = ($vote1['antal'] / ($sam['antal'] / 100)) * 3; $res2 = ($vote2['antal'] / ($sam['antal'] / 100)) * 3; $res3 = ($vote3['antal'] / ($sam['antal'] / 100)) * 3; $res4 = ($vote4['antal'] / ($sam['antal'] / 100)) * 3; $res5 = ($vote5['antal'] / ($sam['antal'] / 100)) * 3; $ress1 = round(($res1 / 3), 2); $ress2 = round(($res2 / 3), 2); $ress3 = round(($res3 / 3), 2); $ress4 = round(($res4 / 3), 2); $ress5 = round(($res5 / 3), 2); $samlet = $sam['antal']; $antal1 = $vote1['antal']; $antal2 = $vote2['antal']; $antal3 = $vote3['antal']; $antal4 = $vote4['antal']; $antal5 = $vote5['antal']; $html = "<font size=\"1\" face=\"verdana\">$emne<br><br>Stemmer i alt: $samlet <br>"; $html .= "<br><table height=\"10\" width=\"$res1\" bgcolor=\"#FF0000\"> <br></table> $ress1 % ($antal1 Stemmer)<br>"; $html .= "<b>$valg1</b><br><table height=\"10\" width=\"$res2\" bgcolor=\"#FF0000\"> <br></table> $ress2 % ($antal2 Stemmer)<br>"; $html .= "<b>$valg2</b><br><table height=\"10\" width=\"$res3\" bgcolor=\"#FF0000\"> <br></table> $ress3 % ($antal3 Stemmer)<br>"; $html .= "<b>$valg3</b><br><table height=\"10\" width=\"$res4\" bgcolor=\"#FF0000\"> <br></table> $ress4 % ($antal4 Stemmer)<br>"; $html .= "<b>$valg4</b><br><table height=\"10\" width=\"$res5\" bgcolor=\"#FF0000\"> <br></table> $ress5 % ($antal5 Stemmer)<br><b>$valg5</b>"; echo $html; } elseif ($_GET["side"] == "resultat") { ?> <b><font size="2" face="verdana">Xyz3D.dk > Afstemning</font></b> <br><br> <? include "db_conn.php"; include "vars.php"; $sql = mysql_query("Select count(*) as antal from vote"); $sam = mysql_fetch_array($sql); $sql = mysql_query("Select count(*) as antal from vote where var = '1'"); $vote1 = mysql_fetch_array($sql); $sql = mysql_query("Select count(*) as antal from vote where var = '2'"); $vote2 = mysql_fetch_array($sql); $sql = mysql_query("Select count(*) as antal from vote where var = '3'"); $vote3 = mysql_fetch_array($sql); $sql = mysql_query("Select count(*) as antal from vote where var = '4'"); $vote4 = mysql_fetch_array($sql); $sql = mysql_query("Select count(*) as antal from vote where var = '5'"); $vote5 = mysql_fetch_array($sql); $res1 = ($vote1['antal'] / ($sam['antal'] / 100)) * 3; $res2 = ($vote2['antal'] / ($sam['antal'] / 100)) * 3; $res3 = ($vote3['antal'] / ($sam['antal'] / 100)) * 3; $res4 = ($vote4['antal'] / ($sam['antal'] / 100)) * 3; $res5 = ($vote5['antal'] / ($sam['antal'] / 100)) * 3; $ress1 = round(($res1 / 3), 2); $ress2 = round(($res2 / 3), 2); $ress3 = round(($res3 / 3), 2); $ress4 = round(($res4 / 3), 2); $ress5 = round(($res5 / 3), 2); $samlet = $sam['antal']; $antal1 = $vote1['antal']; $antal2 = $vote2['antal']; $antal3 = $vote3['antal']; $antal4 = $vote4['antal']; $antal5 = $vote5['antal']; $html = "<font size=\"1\" face=\"verdana\">$emne<br><br>Stemmer i alt: $samlet <br>"; $html .= "<br><table height=\"10\" width=\"$res1\" bgcolor=\"#FF0000\"> <br></table> $ress1 % ($antal1 Stemmer)<br>"; $html .= "<b>$valg1</b><br><table height=\"10\" width=\"$res2\" bgcolor=\"#FF0000\"> <br></table> $ress2 % ($antal2 Stemmer)<br>"; $html .= "<b>$valg2</b><br><table height=\"10\" width=\"$res3\" bgcolor=\"#FF0000\"> <br></table> $ress3 % ($antal3 Stemmer)<br>"; $html .= "<b>$valg3</b><br><table height=\"10\" width=\"$res4\" bgcolor=\"#FF0000\"> <br></table> $ress4 % ($antal4 Stemmer)<br>"; $html .= "<b>$valg4</b><br><table height=\"10\" width=\"$res5\" bgcolor=\"#FF0000\"> <br></table> $ress5 % ($antal5 Stemmer)<br><b>$valg5</b>"; echo $html; } ?>
05. november 2003 - 18:18
#10
koden er ændret men virker ikke, se selv havd den skriver. Men det var vist nok tæt på jeg kan se lidt af resulatatet.
16. marts 2004 - 02:39
#11
hmm
23. marts 2004 - 16:16
#12
Hej, jeg så det lige, nu har jeg tilfældigvis skrevet det script du brokker dig over, hvad er problemet??? jeg kan med rimelig stor sandsynlighed hjælpe dig...
Computerworld tilbyder specialiserede kurser i database-management