Code :
Want to have only latest registered employeeId in drop down list from database ?
public function getEmployeeId() {
if (!isset($_SESSION["email"]) || !isset($_SESSION["passwrd"])) {
header("Location:index.php");
// Cannot Access this page without Login.
}
if (empty($_POST)) {
$query = mysqli_query($this->connection, "SELECT EmployeeId FROM employees") or die("Query execution failed: " . mysqli_error());
while ($row = $query->fetch_array()) {
$id = $row["EmployeeId"];
$_SESSION["ID"] = $id;
}
}
}
Here is my HTML Code Snippet :
<td>
<select name="EmployeeId" required autofocus class='form-control'>
<option value=""> ----Select----</option>
<?php
if (isset($_SESSION["ID"])) {
echo "<option value = " . $_SESSION["ID"] . ">" . $_SESSION["ID"] . "</option>";
}
?>
</select>
</td>
您的查询应为:
SELECT MAX(EmployeeId) AS EmployeeId FROM employees
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.