these are the following codes
for dynamic radio generation
Code: Select all
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$db='tutorial';
$conn = mysqli_connect($dbhost,$dbuser,$dbpass,$db);
if(! $conn )
{
die('Could not connect: ' . error);
}
$sql = 'SELECT * FROM questions';
$result=mysqli_query($conn,$sql)
?>
<form action ="for.php" method="post">
<table width=100% cellspacing="1">
<tr>
<th scope="col"> </th>
</tr>
<th scope="col">
<?php while($rows=mysqli_fetch_array($result)) ?>
<table width=100% cellspacing="1">
<tr>
<th scope="col"> </th>
<input type="radio" name="radio1_1"id="q_1"value="<?php echo $rows['$q1'];?>">
<label for="q1">:<?php echo $rows['$q1'];?></label>
</tr>
</table>
<?php mysqli_close($conn);?>
</th>
</tr>
<tr>
<tr>
<th scope="col"><input type="submit"name="submit"id="submit"value="submit"></th>
<tr>
<table>
</form>
Code: Select all
<?php
$dbuser = 'root';
$dbpass = '';
$db='tutorial';
$dbhost='localhost';
global option1;
global option2;
global option3;
$conn = mysqli_connect($dbhost,$dbuser,$dbpass,$db);
if(! $conn )
{
die('Could not connect: ' . error);
}
$option1=mysqli_real_escape_string($conn, $_POST['option1']);
$option2=mysqli_real_escape_string($conn, $_POST['option2']);
$option3=mysqli_real_escape_string($conn, $_POST['option3']);
$sql = "INSERT INTO feedback (option1,opion2,option3) VALUES ('$option1,$option2,$option3')";
mysqli_close($conn);
?>
please help me
thanks alot in advance