Hi,
I want to list schedules by code, as it is in my sql request ($requete). This code is working, but i think it's not the best way to connect to database. Does another way exist to connect to database safely without writing directly username, host, password and dbname ?
<table class="myTable">
<!-- entête du tableau -->
<thead>
<tr>
<th>#ligne</th>
<th>Dép. ICAO</th>
<th>Arr. ICAO</th>
<th>Appareil</th>
<th>Distance</th>
<th>Prix billet</th>
<th>Opérations</th>
</tr>
</thead>
<?php
$conn = mysqli_connect('host', 'username', 'password', 'dbname');
$requete = "SELECT p.id, p.code, p.flightnum, p.depicao, p.arricao, fullname, p.distance, p.price FROM phpvms_schedules p INNER JOIN phpvms_aircraft a ON p.aircraft=a.id WHERE code='XXX'";
$res = $conn->query($requete);
while ($element = mysqli_fetch_array($res)) {
echo '<tbody>';
echo '<tr>';
echo '<td>'.$element['code'].' - '.$element['flightnum'].'</td>
<td>'.$element['depicao'].'</td>
<td>'.$element['arricao'].'</td>
<td>'.$element['fullname'].'</td>
<td>'.ceil($element['distance']).' nm</td>
<td>'.$element['price'].' €</td>
<td><a href="'.SITE_URL.'/index.php/schedules/brief/'.$element['id'].'">Briefing</td>';
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
?>
Thanks for helping me,
Best regards