我的數據表中存儲數到行。現在我想和他們一起創建桌子。我想箱子X
行和Y
列。我知道我應該使用,同時或foreach
循環,但我不知道如何... :(如何在環環...? PHP - 庫MySQLi
$result = $db->query(
"SELECT `x`,`y`,`noe` FROM `table` "
. "WHERE (`x` >= 0 and `x` < 4) and (`y` >= 0 and `y` < 4) "
. "ORDER BY `x`,`y` ASC") or die($db->error);
if($result) {
echo "<pre>",$result->num_rows,"</pre>";
echo "<pre>", print_r($row = $result->fetch_object()),"</pre>";
?>
<table>
<?php
while($row = $result->fetch_all()){
//echo "X: ", $row->x, " ,Y: ", $row->y," ,Type of item: ", $row->noe,"<br>";
echo '<tr><td>',$row->x,'-',$row->y,'</td></tr>';
}
}
?>
</table>
在這種情況下,「X」行和「Y」列是什麼意思? – asprin
@asprin我想創建這樣的東西:http://uploadco.ir/uploads/ohxpfv53d09fx445odoj.png –