Need HELP urgently in dyanmic radio button generation,insert
Posted: Fri Jan 27, 2017 3:53 am
i need urgent help please help me out in the following code i want to generate radio button from the values of mysql db in radio button format and want to insert in other table
these are the following codes
for dynamic radio generation
THE OTHER CODE FOR INSERTION INTO DATABASE
the code is not producing any error for display of radio button but not showing any output
please help me
thanks alot in advance
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