<?php
$ime_prezime="";
$email="";
$con = mysqli_connect("localhost","root","","tvz");
$result1=$con->query("SELECT naziv FROM mentori");
$result2=$con->query("SELECT ime_prezime FROM studenti");
<form action="index.php" method="POST">
<h1>Izbor mentora</h1>
<div class="text-center">
<h2>Mentor</h2>
<select class="chosen" name="mentor">
<?php
while($rows=$result1->fetch_assoc())
{
$ime_prezime=$rows['naziv'];
echo "<option value='$ime_prezime'>$ime_prezime</option>";
}
?>
</select>
<h2>Vase ime</h2>
<select class="chosen" name="student">
<?php
while($rows=$result2->fetch_assoc())
{
$email=$rows['ime_prezime'];
echo "<option value='$email'>$email</option>";
}
?>
</select>
</div>
<input type="Submit" class="ok" name="register_button" value="Update">
</form>
<?php
$_SESSION['ime_prezime'] = $email;
$_SESSION['naziv'] = $ime_prezime;
if(isset($_POST['register_button'])){
$id = mysqli_query($con, "SELECT id FROM mentori WHERE
naziv=$ime_prezime");
echo "$id";
$query = mysqli_query($con, "UPDATE studenti SET id_mentor='$id' WHERE
ime_prezime='ivanic'");
}
?>
我已添加所有内容,但不会应用到我的数据库中