I have created a drop down list that is populated by data from mysql db, im trying to save the selected value in a session variable but im not sure how to write this (where the *** are)? And does it need to be posted to server side eve though its all in php?
<?php
$servername1 = "localhost";
$username1 = "root";
$password1 = "";
$dbname1 = "gpdb1";
$conn1 = new mysqli($servername1, $username1, $password1, $dbname1);
if ($conn1->connect_error) {
die("connection failed: " . $conn1->connect_error);
}
$sql2 = "SELECT DoctorID, Title, Surname FROM doctors";
$result2 = $conn1->query($sql2);
echo "<select name='doctor' value=''><option>Select a Doctor</option>";
if ($result2->num_rows > 0) {
foreach($result2 as $row2)
{echo "<option value=".$row2['DoctorID'].">".$row2['Title']." ".$row2['Surname']."</option>";
}
}echo "</select>";
$_SESSION['selected']=***;
if (isset($_SESSION['selected'])){
echo $SESSION['selected'];}
?>
Thanks :)