I want to get a value from the checked radio button and insert it to MySQL.
I've already used isset(), but when i checked the result, I can't get the selected radio button.
Can someone help me?
<form method="post" class="input" action="doRegisCourse.php">
<table>
<?php
while($row=mysql_fetch_array($query)){
?>
<tr>
<td><input type="radio" value="mentor" name="mentor"/></td>
<td><?php echo $row['mentorName']?></td>
<td><?php echo $row['course']?></td>
<td><?php echo $row['nim']?></td>
<td><?php echo $row['email']?></td>
</tr>
<?php } ?>
</table>
<input type="submit" value="Next" name="submit">
</form>
doRegisCourse.php
<?php
include "connect.php";
$name = $_POST['fullname'];
$name2 = $_POST['fullname2'];
$name3 = $_POST['fullname3'];
$course = $_POST['course'];
$mentor = mysql_query("SELECT * from msmentor");
$i = 1;
while ($arr = mysql_fetch_array($mentor)) {
if (isset($_POST['mentor'])) {
$query = "INSERT INTO membercourse(memberGroup,courseName,mentorName)
VALUES ('".$name."','".$course."','".$arr['mentorName']."'),('".$name2."','".$course."','".$arr['mentorName']."'),
('".$name3."','".$course."','".$arr['mentorName']."')";
echo $_POST['mentor'];
}
$i++;
}
if (mysql_query($query)) {
header("location:indexLogin.php");
}
the echo $_POST['mentor'] returns this 'mentormentormentormentor'