html code:
<tr> <td id="qn1" name="qn1">1</td> <td>Presentation of course overview and relevant references</td> <td> <select class="form-control" name="select"> <option value="very good">Very Good</option> <option value="good">Good</option> <option value="average">Average</option> <option value="poor">Poor</option> <option value="very poor">Very Poor</option> </select> </td> </tr>
php code:
<?php
$servername = "localhost";
$username = "root";
$password ="";
$dbname = "surveyproject";
//establish connection
$connection = mysqli_connect($servername , $username,$password ,$dbname);
//check for connection errors
if ($connection->connect_error) {
die("Connection failed: " . $connection->connect_error);
}
echo "connected succesfully";
//inserting answers into db
if (isset($_POST['submit'])) {
if(isset($_POST['select']) && isset($_POST['qn1'])){
$select = $_POST['select'];
$qn = $_POST['qn1'];
$query="INSERT INTO surveyanswers (quest_id,answer) VALUES
('$select','$qn')";
mysqli_query($query);
}
echo "<script>alert('succesfully submitted answers , thankyou'</script>";
}
mysqli_close($connection);
?>