0
我的排序問題,我不明白是什麼問題。 我有一個表MYSQL ORDER BY未按預期方式顯示
id id_teacher subject class hour day
1 2 [->] Math X C 8 Monday
2 2 [->] Math X C 12 Wednesday
3 2 [->] Math X C 9 Tuesday
4 2 [->] Math VI B 10 Monday
5 2 [->] Math X C 11 Monday
6 2 [->] Math X C 10 Tuesday
7 5 [->] Chimie X C 9 Monday
8 5 [->] Chimie X C 12 Monday
9 2 [->] Sport X C 7 Monday
而且我有我打印「小時」和「主體」的功能。該功能是這樣的:
function OreMonday($item){
$sth = $this->dbh->prepare("SELECT class FROM elevi WHERE id_elev = :id_elev;");
$sth->bindParam(":id_elev", $item);
$sth->execute();
$result = $sth->fetch(PDO::FETCH_ASSOC);
$sth1 = $this->dbh->prepare("SELECT hour, subject, day FROM hourr WHERE class = :class ORDER BY hour DESC;");
$sth1->bindParam(":class", $result['class']);
$sth1->execute();
while ($result1 = $sth1->fetch(PDO::FETCH_ASSOC)) {
if ($result1['day'] == 'Monday') {
echo $result1['hour'];
echo $result1['subject']."<br>";
}
}
}
}
$產品$ _SESSION [ '身份證']和$結果[ '類']從另一個聲明
結果是XC是這樣的:
Monday
9Chimie
8Math
7Sport
12Chimie
11Math
而且我想:
Monday
7Sport
8Math
9Chimie
11Math
12Chimie
列'hour'的數據類型是什麼? – AlexP