Drop down selection not showing up in MySQL. How do I get the selection from the MySQL-populated drop down list to be a value I can use when creating a new record?
<?php
include_once 'dbcon.php';
if(isset($_POST['save_mul']))
{
$total = $_POST['total'];
for($i=1; $i<=$total; $i++)
{
$sname = $_POST["sname$i"];
$sql="INSERT INTO users(speaker) VALUES ('".$sname."')";
$sql = $MySQLiconn->query($sql);
}
if($sql)
{
?> <script>
alert('<?php echo $total." records was inserted !!!"; ?>');
window.location.href='index.php';
</script> <?php
}
else
{
?> <script>
alert('error while inserting , TRY AGAIN');
</script> <?php
}
}
?> <html> <td><select name="room<?php echo $i; ?>" class="form-control action"> <?Php
$mysqli = new mysqli("localhost","root","","challenge_db");
$sqlSelect="SELECT DISTINCT room_name FROM ref_room";
$result = $mysqli -> query ($sqlSelect);
echo '<OPTION value="">';
echo "Select an option</OPTION>";
while ($row = mysqli_fetch_array($result)) {
$rname = $row["room_name"];
echo "<OPTION value=''>$rname</OPTION>";
}
?> </select></td>