I have table of data that store number into the rows. Now I wanna to create table with them. I want to crate X rows and Y columns. I know I should use while or foreach loop but I don't know how... :(
$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>
Xrows andYcolumns mean in this context?