I have an issue with my table. I already set the table width and also the th
width. But when the td
displays data from the database, the td
size is not as the same as set at th
. The td
size follows which td
has long text. I want to make all the td
fixed according to the width that I set. Could anyone guide me how to achieve what I am trying to do? Below is the code:
echo "<table class='table table-bordered' width = '100%'>";
echo "<thead>";
echo "<tr>";
echo "<th width = '5%'>#</th>
<th width = '15%'>Requester</th>
<th width = '5%'>Factory</th>
<th width = '20%'>Room</th>
<th width = '25%'>Purpose</th>
<th width = '10%'>Status</th>
<th width = '20%'>Action</th>
</tr>
</thead>
<tbody >";
$query = $conn->query("SELECT * FROM booking LEFT JOIN room ON booking.Room_ID = room.Room_ID WHERE Admin_email = '$Email' AND EndTime > GETDATE() ORDER BY booking.Book_No DESC");
while($row = $query->fetch(PDO::FETCH_ASSOC)){
$status=$row['Book_Status'];
if($status=="Approve")
{
$color="color:green";
}
else if($status=="Pending")
{
$color="color:blue";
}
else
{
$color="color:red";
}
echo "<tr>";
echo "<td>" . $row['Book_No'] . "</td>";
echo "<td>" . $row['Requested_by'] . "</td>";
echo "<td>" . $row['Fac_ID'] . "</td>";
echo "<td>" . $row['Room_Desc'] . "</td>";
echo "<td>" . $row['Meeting_Description'] . "</td>";
echo "<td style='$color'><strong>" . $status ."</strong></td>";
echo "<td>";
echo "<a class='btn-view btn-primary btn-sm' href='../../view_booking/admin/view_booking.php?Book_No=". $row['Book_No'] ."' data-toggle='tooltip'>View</a>";
echo "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table><br>";