this is probably a very simple question to solve, however I've been stuck with this for a while and I can't figure out for the life of me what's wrong with my code. It may be just a syntax mistake but I've gathered this code from other questions and it should work but I keep getting the errors : - Undefined variable : mysqli and - Call to a member function query() of a non-object , both in the line "$result = $mysqli->query($sql);".
Here's the snippet of my code where I have the dropdown menu set up.
<label class="control-label" for="formInput85">Professor</label>
                                           
<?php
$sql = "SELECT name FROM professores";
$result = $mysqli->query($sql);
echo "<select class=".'"form-control"'.">";
while ($row = $result->fetch_assoc()) {
echo "<option value='" . $row['name'] . "'>" . $row['name'] . "</option>";
}
echo "</select>";
?>And here's my code in the very beginning of the page, that is connecting to my database in phpmyadmin.
<?php
 session_start();
 echo $_SESSION['name'];
 
 $servername = "localhost"; 
 $username = "root"; 
 $password = ""; 
 $dbname = "teste"; 
 $conn = new mysqli($servername,$username,$password,$dbname); 
?>Thank you for your help! If you have any tips on how to send the value selected into another row of the table I gladly appreciate it as it will be my next step :)
 
    