Avatar billede kingrex666 Nybegynder
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.
Avatar billede ztyxx Nybegynder
04. november 2003 - 02:09 #1
Not Found
The requested URL /p/form.php was not found on this server.
Avatar billede ztyxx Nybegynder
04. november 2003 - 02:10 #2
nu kan jeg se den, læg lige koden...
Avatar billede kingrex666 Nybegynder
04. november 2003 - 02:10 #3
prøv igen er lige opdateret
Avatar billede kingrex666 Nybegynder
04. november 2003 - 02:11 #4
hvilke en af dem?
Avatar billede ztyxx Nybegynder
04. november 2003 - 02:11 #5
vote.php og form.php
Avatar billede kingrex666 Nybegynder
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\">&nbsp;<br></table> $ress1 % ($antal1 Stemmer)<br>";
    $html .= "<b>$valg1</b><br><table height=\"10\" width=\"$res2\" bgcolor=\"#FF0000\">&nbsp;<br></table> $ress2 % ($antal2 Stemmer)<br>";
    $html .= "<b>$valg2</b><br><table height=\"10\" width=\"$res3\" bgcolor=\"#FF0000\">&nbsp;<br></table> $ress3 % ($antal3 Stemmer)<br>";
    $html .= "<b>$valg3</b><br><table height=\"10\" width=\"$res4\" bgcolor=\"#FF0000\">&nbsp;<br></table> $ress4 % ($antal4 Stemmer)<br>";
    $html .= "<b>$valg4</b><br><table height=\"10\" width=\"$res5\" bgcolor=\"#FF0000\">&nbsp;<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\">&nbsp;<br></table> $ress1 % ($antal1 Stemmer)<br>";
    $html .= "<b>$valg1</b><br><table height=\"10\" width=\"$res2\" bgcolor=\"#FF0000\">&nbsp;<br></table> $ress2 % ($antal2 Stemmer)<br>";
    $html .= "<b>$valg2</b><br><table height=\"10\" width=\"$res3\" bgcolor=\"#FF0000\">&nbsp;<br></table> $ress3 % ($antal3 Stemmer)<br>";
    $html .= "<b>$valg3</b><br><table height=\"10\" width=\"$res4\" bgcolor=\"#FF0000\">&nbsp;<br></table> $ress4 % ($antal4 Stemmer)<br>";
    $html .= "<b>$valg4</b><br><table height=\"10\" width=\"$res5\" bgcolor=\"#FF0000\">&nbsp;<br></table> $ress5 % ($antal5 Stemmer)<br><b>$valg5</b>";
    echo $html;
   
    } ?>
Avatar billede kingrex666 Nybegynder
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>
Avatar billede kingrex666 Nybegynder
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 !!!
Avatar billede ztyxx Nybegynder
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\">&nbsp;<br></table> $ress1 % ($antal1 Stemmer)<br>";
    $html .= "<b>$valg1</b><br><table height=\"10\" width=\"$res2\" bgcolor=\"#FF0000\">&nbsp;<br></table> $ress2 % ($antal2 Stemmer)<br>";
    $html .= "<b>$valg2</b><br><table height=\"10\" width=\"$res3\" bgcolor=\"#FF0000\">&nbsp;<br></table> $ress3 % ($antal3 Stemmer)<br>";
    $html .= "<b>$valg3</b><br><table height=\"10\" width=\"$res4\" bgcolor=\"#FF0000\">&nbsp;<br></table> $ress4 % ($antal4 Stemmer)<br>";
    $html .= "<b>$valg4</b><br><table height=\"10\" width=\"$res5\" bgcolor=\"#FF0000\">&nbsp;<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\">&nbsp;<br></table> $ress1 % ($antal1 Stemmer)<br>";
    $html .= "<b>$valg1</b><br><table height=\"10\" width=\"$res2\" bgcolor=\"#FF0000\">&nbsp;<br></table> $ress2 % ($antal2 Stemmer)<br>";
    $html .= "<b>$valg2</b><br><table height=\"10\" width=\"$res3\" bgcolor=\"#FF0000\">&nbsp;<br></table> $ress3 % ($antal3 Stemmer)<br>";
    $html .= "<b>$valg3</b><br><table height=\"10\" width=\"$res4\" bgcolor=\"#FF0000\">&nbsp;<br></table> $ress4 % ($antal4 Stemmer)<br>";
    $html .= "<b>$valg4</b><br><table height=\"10\" width=\"$res5\" bgcolor=\"#FF0000\">&nbsp;<br></table> $ress5 % ($antal5 Stemmer)<br><b>$valg5</b>";
    echo $html;
   
    } ?>
Avatar billede kingrex666 Nybegynder
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.
Avatar billede kingrex666 Nybegynder
16. marts 2004 - 02:39 #11
hmm
Avatar billede -xyz- Nybegynder
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...
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Computerworld tilbyder specialiserede kurser i database-management

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester