Beste SD'er,
Ik ben bezig aan een test waar per vraag 5 verschillende antwoorden mogelijk zijn (radiobuttons). Deze html staat in de productie_tmp.php echter lukt het mij niet de score berekening in de productie.php juist te laten gebeuren. Volgens mij wordt het op verkeerde volgorde in actie gezet. Hopelijk kunt u mij misschien helpen? Hier gaat het om:
PHP Code:
<?php if(!isset($RUN)) { exit(); } ?>
<body>
<div align="center" >
<form action="productie.php" method="post" id="1">
<table style=" border:1px solid black; margin-top:50px; padding: 5px; background-color:white;">
<tr>
<td> Ik weet goed ...</td>
<td>
<input type="radio" name="prestatie1" value="1"> optie 1</td><td>
<input type="radio" name="prestatie1" value="2"> Optie 2</td><td>
<input type="radio" name="prestatie1" value="3"> Optie 3 </td><td>
<input type="radio" name="prestatie1" value="4"> Optie 4</td><td>
<input type="radio" name="prestatie1" value="5"> Optie 5 <br>
</td>
</tr><tr>
<td>Ik zorg ...</td>
<td>
<input type="radio" name="prestatie2" value="1"> optie 1</td><td>
<input type="radio" name="prestatie2" value="2"> Optie 2</td><td>
<input type="radio" name="prestatie2" value="3"> Optie 3 </td><td>
<input type="radio" name="prestatie2" value="4"> Optie 4</td><td>
<input type="radio" name="prestatie2" value="5"> Optie 5 <br>
</td>
</tr>
<tr>
<td> Ik heb ...</td>
<td>
<input type="radio" name="prestatie3" value="1"> optie 1</td><td>
<input type="radio" name="prestatie3" value="2"> Optie 2</td><td>
<input type="radio" name="prestatie3" value="3"> Optie 3 </td><td>
<input type="radio" name="prestatie3" value="4"> Optie 4</td><td>
<input type="radio" name="prestatie3" value="5"> Optie 5 <br>
</td>
</tr><tr>
<td>Ik blijf goed functioneren ... </td>
<td>
<input type="radio" name="prestatie4" value="1"> optie 1</td><td>
<input type="radio" name="prestatie4" value="2"> Optie 2</td><td>
<input type="radio" name="prestatie4" value="3"> Optie 3 </td><td>
<input type="radio" name="prestatie4" value="4"> Optie 4</td><td>
<input type="radio" name="prestatie4" value="5"> Optie 5 <br>
</td>
</tr>
<tr>
<td> Ik krijg ...</td>
<td>
<input type="radio" name="prestatie5" value="1"> optie 1</td><td>
<input type="radio" name="prestatie5" value="2"> Optie 2</td><td>
<input type="radio" name="prestatie5" value="3"> Optie 3 </td><td>
<input type="radio" name="prestatie5" value="4"> Optie 4</td><td>
<input type="radio" name="prestatie5" value="5"> Optie 5 <br>
</td>
</tr><tr>
<td>Ik onderhoud goed ...</td>
<td>
<input type="radio" name="prestatie6" value="1"> optie 1</td><td>
<input type="radio" name="prestatie6" value="2"> Optie 2</td><td>
<input type="radio" name="prestatie6" value="3"> Optie 3 </td><td>
<input type="radio" name="prestatie6" value="4"> Optie 4</td><td>
<input type="radio" name="prestatie6" value="5"> Optie 5 <br>
</td>
</tr>
<tr>
<td>Goed samenwerken ...</td>
<td>
<input type="radio" name="prestatie7" value="1"> optie 1</td><td>
<input type="radio" name="prestatie7" value="2"> Optie 2</td><td>
<input type="radio" name="prestatie7" value="3"> Optie 3 </td><td>
<input type="radio" name="prestatie7" value="4"> Optie 4</td><td>
<input type="radio" name="prestatie7" value="5"> Optie 5 <br>
</td>
</tr><tr>
<td>Ik blijf goed ...</td>
<td>
<input type="radio" name="prestatie8" value="1"> optie 1</td><td>
<input type="radio" name="prestatie8" value="2"> Optie 2</td><td>
<input type="radio" name="prestatie8" value="3"> Optie 3 </td><td>
<input type="radio" name="prestatie8" value="4"> Optie 4</td><td>
<input type="radio" name="prestatie8" value="5"> Optie 5 <br>
</td>
</tr>
</table>
<div align="center">
<INPUT TYPE="button" NAME= "volgende" VALUE="Volgende stap" onclick="window.location.href='index.php?module=coping'">
</div>
</form>
</div>
<?php
?>Hte uiteindelijke doel is om bij op volgende klikken dat dan de $totscorepro met userID en en Date wordt geplaatst in het tabel, later worden de andere scores op onderdelen met update gedaan. Bij voorbaat dank!PHP Code:
<?php if(!isset($RUN)) { exit(); } ?>
<?php
$connect = mysql_connect("localhost","***","****");
if (!$connect)
{
die("MySQL could not connect!");
}
$DB = mysql_select_db('vooren21_quiz');
if(!$DB)
{
die("My SQL could not select Database!");
}
$scoreproq1 = $_POST['prestatie1'];
$scoreproq2 = $_POST['prestatie2'];
$scoreproq3 = $_POST['prestatie3'];
$scoreproq4 = $_POST['prestatie4'];
$scoreproq5 = $_POST['prestatie5'];
$scoreproq6 = $_POST['prestatie6'];
$scoreproq7 = $_POST['prestatie7'];
$scoreproq8 = $_POST['prestatie8'];
$totscorepro = $scoreproq1 + $scoreproq2 + $scoreproq3 + $scoreproq4 + $scoreproq5 + $scoreproq6+ $scoreproq7 + $scoreproq8;
INSERT INTO `vooren21_quiz`.`wpm_scores` (`testID`, `userID`, `scorepro`, `scorecop`, `scoresam`, `scoremot`, `date`) VALUES ('2', '232', '$totscorepro', '25', '23', '16', '2012-08-12 00:00:00');
//Beter een functie gebruiken?:
//score10inv($totscorepro);
echo $totscorepro;
?>
Met vriendelijke groet,
Jesper
- tmp.php en php met mysql
-
12-08-2012, 17:48 #1
- Berichten
- 24
- Lid sinds
- 13 Jaar
tmp.php en php met mysql
-
-
12-08-2012, 18:42 #2
- Berichten
- 49
- Lid sinds
- 13 Jaar
Re: tmp.php en php met mysql
Beste Jesper,
Wat lukt er precies niet? Wat gaat er precies fout?
Met deze informatie kan ik je iets beter helpen.
Met vriendelijke groet,
Jasper
-
12-08-2012, 20:01 #3
- Berichten
- 24
- Lid sinds
- 13 Jaar
Re: tmp.php en php met mysql
Beste Jasper,
Bedankt voor een snelle reactie. Mijn ervaring met php is niet uitgebreid, het lukt me om een postfunctie te gebruiken en met php in een ander bestand te berekenen en ook het in een database plaatsen. Echter heb ik een gratis script gebruikt van http://www.aspnetpower.com/elsphpwebquiz/ Hierin worden modules gebruikt met een modulenaam_tmp.php file en modulenaam.php Het lukt me niet om de data te verwerken nadat het is ingevuld in de html. Er moet een actie komen: dat als er op volgende wordt geklikt dat de gegevens worden berekent in de modulenaam.php en dan worden gezonden naar de database.
-
13-08-2012, 10:06 #4
- Berichten
- 69
- Lid sinds
- 18 Jaar
Re: tmp.php en php met mysql
Haal uit je <input type="button" ...> dit weg:
onclick="window.location.href='index.php?module=co ping'"
En zet om die regel van INSERT INTO dit:
mysql_query();
-
13-08-2012, 10:18 #5
- Berichten
- 980
- Lid sinds
- 17 Jaar
Re: tmp.php en php met mysql
<INPUT TYPE="submit" NAME="volgende" VALUE="Volgende stap" />
Verder moet inderdaad je query nog in een php mysql_query gezet worden en een functie zou inderdaad verstandig zijn. Wellicht dat het ook slim is om alvast mysqli te gebruiken in plaats van mysql die over een paar php-versies niet meer ondersteund wordt.
Succes!
-
13-08-2012, 12:17 #6
- Berichten
- 69
- Lid sinds
- 18 Jaar
Re: tmp.php en php met mysql
@Daniel.
De input-type kan prima "button" zijn. Wellicht wil de TS zijn button namelijk stylen en dat kan makkelijker met type="button". Verder hebben type="submit" en type="button" dezelfde functie: een formulier verzenden.
Het enige verschil is de afhandeling in PHP, maar op de manier zoals de TS het nu heeft maakt dat niet uit.
Verder zeg je eigenlijk hetzelfde als wat ik zei.
-
15-08-2012, 08:25 #7
- Berichten
- 980
- Lid sinds
- 17 Jaar
Re: tmp.php en php met mysql
Tim, er staat nog een spatie achter name=
<INPUT TYPE="button" NAME= "volgende" VALUE="Volgende stap" onclick="window.location.href='index.php?module=co ping'">
-
15-08-2012, 20:54 #8
- Berichten
- 69
- Lid sinds
- 18 Jaar
Re: tmp.php en php met mysql
Zolang er tussen de = en de eerste " maar niets anders staat.
Probeer het maar eens uit.
Plaats een
- + Advertentie
- + Onderwerp
Marktplaats
Webmasterforum
- Websites algemeen
- Sitechecks
- Marketing
- Domeinen algemeen
- Waardebepaling
- CMS
- Wordpress
- Joomla
- Magento
- Google algemeen
- SEO
- Analytics
- Adsense
- Adwords
- HTML / XHTML
- CSS
- Programmeren
- PHP
- Javascript
- JQuery
- MySQL
- Ondernemen algemeen
- Belastingen
- Juridisch
- Grafisch ontwerp
- Hosting Algemeen
- Hardware Info
- Offtopic