所以我有一个循环,它从我的数据库中吐出每一行数据。输出显示如下
Array ( [0] => 1 [1] => 1 [2] => 1 [3] => Saratoga [4] => test [5] => 7-2 [6]
=> Red [7] => Bob [8] => Jill )
Array ( [0] => 2 [1] => 1 [2] => 2 [3] => Saratoga [4] => test 2 [5] => 3-3 [6]
=> White [7] => Bill [8] => Austin )
Array ( [0] => 3 [1] => 1 [2] => 3 [3] => Saratoga [4] => test 3 [5] => 2-2
[6] => Blue [7] => Austin [8] => jill )
我如何将它组合成一个数组?
下面的代码是关于我如何为我的数组做循环的
$sql = "SELECT * FROM `2018-08-20`";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
$rn = 1;
// output data of each row
$aa = 1;
while($row = $result->fetch_assoc()) {
$a = array($aa,$row["RaceNumber"], $row["HorseNum"], $row["Track"],
$row["HorseName"], $row["Odds"], $row["Color"], $row["JockeyName"],
$row["TrainerName"] );
for($x=0;$x < $a[1];$x++){
$aa++;
print_r($a);
echo "<br/>";
$rn++;
}
}
echo ' <button type="submit" name="submit"> Submit </button></form>';
echo "</table>";
} else {
echo "0 results";
}