sch プロジェクトを行っていますが、ヘッダー行をクリックしてデータ テーブルをアルファベット順に並べ替えるのに助けが必要です。私は MySQL を使用しており、それを実装するために PHP を使用するつもりです。誰でも私を助けることができますか?ありがとう。
これは私のコードです:
これはphpファイルです。
<?php
@ $db = new mysqli('localhost', 'f33s01', 'f33s01', 'f33s01');
if (mysqli_connect_errno()) {
echo 'Error: Could not connect to database. Please try again later.';
exit;
}
$query = "select * from gyms";
$result = $db->query($query);
$num_results = $result->num_rows;
echo "<table border=\"3\" cellpadding=\"5\" class=\"dirtable\" style=\"margin-bottom:15px\">
<tr align=\"center\" class=\"gold\">
<th>Number</th>
<th>Gym Name</th>
<th>Address</th>
<th>Location</th>
<th width=\"18%\">Operating Hours</th>
<th>Reservation</th>
</tr>";
for ($i=0; $i <$num_results; $i++) {
$row = $result->fetch_assoc();
echo "<tr>";
echo "<td align=\"center\">".($i+1)."</td>";
echo "<td align=\"center\">".stripslashes($row['gymname'])."</td>";
echo "<td>".stripslashes($row['address'])."</td>";
echo "<td>".stripslashes($row['location'])."</td>";
echo "<td align=\"center\">".stripslashes($row['operatinghours'])."</td>";
echo "<td align=\"center\"><input type= \"submit\" value=\"BOOK NOW\" class=\"bookbutton\"></td>";
echo "</td>";
echo "</tr>";
}
echo "</table>";
echo "</form>";
$result->free();
$db->close();
?>