Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //get logged in username
- $username = $_SESSION['username'];
- //connect to the database
- include ('connect.php');
- $query = ("SELECT * FROM staff WHERE username ='$username'");
- $result = mysqli_query($connect, $query);
- //fetch associative array
- while($row = mysqli_fetch_assoc($result)){
- //get staff id
- $id = $row['staff_id'];
- //Join staff and class tables o foreign key class_year and select all data based on the staff id
- $sql = "SELECT * FROM staff INNER JOIN class ON staff.class_year = class.class_year WHERE staff_id = '$id' ";
- $result = mysqli_query($connect, $sql);
- if ($result->num_rows > 0) {
- ?>
- <select name = "class_year">
- <option selected="selected" disabled='disabled'>Please Select</option>
- <?php
- while($row1 = mysqli_fetch_array($result)) {
- ?>
- <option><?php echo $row1['class_year'];?></option>
- <?php
- }
- }
- ?>
- </select>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement