Jump to content

php / mysql and forms variables


romano2717

Recommended Posts

I need help to this problem that i've been tackling for quite a few days now..

see, I made a database driven quiz, wherein questions and choices are saved and retrieve in the database.

the choices are displayed beside the radio button, there will be four radio buttons per question.

the problem now is I dont know how to get the checked values of my radio buttons. I think i have something to change in my form with the way i name my form variables.. is there a way to display the checked values of the radio buttons? please i really need help.. cheers! heres the code.

 

<?php

session_start();

//connect to database

include('connect.php');

 

//initz variables

$made = $_SESSION['inst'];

$topic = $_SESSION['topic'];

$num = $_SESSION['num'];

$sql = " SELECT * FROM questionnaires_table WHERE made = '".$made."'

AND topic = '".$topic."' LIMIT $num";

$result = mysql_query($sql)or die("query failed, di mka fetch".mysql_error());

$count = mysql_num_rows($result);

?>

<html>

<head><title>OIPLT evaluation</title></head>

<body>

<?php

echo '<form method="get" action="evaluate_score.php">

<table align = "center" border = "1" width = "75%">';

if($_GET['start']){

while($row = mysql_fetch_assoc($result)){

$a = $row['a'];

$b = $row['b'];

$c = $row['c'];

$d = $row['d'];

$ques = $row['ques'];

$quesId = $row['quesId'];

echo'

<tr>

<td align = "left"><b>'.$ques.'</b></td>

</tr>

<tr>';

echo" <td align = 'left'>

<input type = 'radio' name=q$quesId value='$a'>{$a}

</td>

</tr>";

echo" <tr>

<td align = 'left'>

<input type = 'radio' name=q$quesId value='$b'>{$b}

</td>

</tr>";

echo " <tr>

<td align = 'left'>

<input type = 'radio' name=q$quesId value='$c'>{$c}

</td>

</tr>";

echo" <tr>

<td align = 'left'>

<input type = 'radio' name=q$quesId value='$d'>{$d}

</td>

</tr>";

}

}

echo "

<tr>

<td align='center'><input type='submit' name='sub' value='Finish'></td>

</tr>

</table>";

?>

</form>

</body>

</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.