I am fairly new to this so I'll give it my best shot to describe the issue I am having:
The website I am creating allows users to input their information (studentID, firstname, lastname, college, major, etc.) and I am trying to allow each user to update their information using a similar form they used to register in the first place.
The updateInformation.php form has text boxes with values set from mysql when the page is entered, including a dropdown box to select their college from a list that I manually added to the php code (it does not populate the from an sql query, and I would like to keep it that way if possible). Below is the code I used for the table:
Code:
$mainMenu = <<<EOBODY
<br /><u>Please select a school or college of study:</u><br /><br />
<select name="school"> Selected="$recordArray[school]"
<option value="AGNR">School of Agriculture and Natural Resources</option>
<option value="ARPP">School of Architecture, Planning, and Preservation</option>
<option value="ARHU">College of Arts and Humanities</option>
<option value="BSOS">College of Behavioral and Social Sciences</option>
<option value="BMGT">Robert H. Smith School of Business</option>
<option value="CMNS">College of Computer, Mathematical and Natural Sciences</option>
<option value="CoED">College of Education</option>
<option value="ENES">A. James Clark School of Engineering</option>
<option value="JOUR">Philip Merrill College of Journalism</option>
<option value="SoPH">School of Public Health</option>
<option value="UNDE">Undecided</option>
</select>
EOBODY;
The issue I am having is setting the selected value to be the value that is in the mysql DB. How would I insert php code so that it would auto-select the option that the user previously chosen? i.e. if the user was in "College of Arts and Humanities", the value "ARHU" would be selected by default.
If it helps, here is the code I used to access the database:
Code:
session_start();
if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) {
header ("Location: login.php");
}
$title = "Study Buddy: University of Maryland";
$db = accessApplicationDB();
$query = "select * ".
"from currentCourses, Student ".
"where Student.studentID = '$_SESSION[studentID]' AND ".
"Student.studentID = currentCourses.studentID";
$result = mysqli_query($db, $query);
if ($result) {
$numberOfRows = mysqli_num_rows($result);
if ($numberOfRows == 0) {
$body = "<h2>Invalid University ID " . $_SESSION['studentID'] . " provided.</h2>";
} else {
$recordArray = mysqli_fetch_array($result, MYSQLI_ASSOC);
Thank you for your help!