$sqlFindPath = "select id, type, children from scores order by type, children desc";
$stmt = $conn->prepare($sqlFindPath);
$stmt->execute();
$stmt->bindColumn('id',$id);
$stmt->bindColumn('type',$type);
$stmt->bindColumn('children',$total);
$hasUnapproved = $stmt->rowCount();
if($hasUnapproved >= 1) {
while($row = $stmt->fetch(PDO::FETCH_BOUND)) {
echo $id.' '.$type.' '.$total.'<br>';
}
} else {
echo 'Nothing found';
}
您在下面看到的是我使用上面选择的数据。如何按类型使用来自 mySql 的 php 输出数据?
期望的输出
Ex:
Type 1;
"2" "1" "60"
"1" "1" "50"
Type 2
"3" "2" "10"
"4" "2" "5"
"5" "2" "1"
Type 3
"6" "3" "10"
"7" "3" "2"
从表中选择的数据
"id" "type" "children"
"2" "1" "60"
"1" "1" "50"
"3" "2" "10"
"4" "2" "5"
"5" "2" "1"
"6" "3" "10"
"7" "3" "2"