Having an issue getting the MySQL Data in my Database. I don’t know if the code is fine or I have missed something, please give me an idea of how to get the data from my database.
This is my Query in Time Data
<?php
$query = "SELECT * from timetable";
$result = mysqli_query($db, $query);
if($result){
while($row=mysqli_fetch_array($result)){
$t_id=$row["t_id"];
$time=$row["t_time"];
$t_time=date("h:i A", strtotime($row["t_time"])); ?>
<option <?php echo $update && $up_time == $time ? 'selected' : ''; ?> value='<?= $time ?>'><?= $t_time ?><br></option>
<?php }
}
?>
This is my Query in my Employee Data
<?php
$query = "SELECT * from employee";
$result = mysqli_query($db, $query);
if($result){
while($row=mysqli_fetch_array($result)){
$e_id=$row["id"];
$name=$row["e_name"]; ?>
<option <?php echo $update && $up_employee == $e_id ? 'selected' : ''; ?> value="<?= $e_name ?>"><?= $name ?><br></option>
<?php
}
}
?>
Advertisement
Answer
Did you connect and selected the database: $db = mysqli_connect(...);
(I am not sure if the <br> is ok inside the <option>.)

