示例:
<?php
$cars = array
(
array("Volvo",22,18),
array("BMW",15,13),
array("Saab",5,2),
array("Land Rover",17,15)
);
echo $cars[0][0].": In stock: ".$cars[0][1].", sold: ".$cars[0][2].".<br>";
echo $cars[1][0].": In stock: ".$cars[1][1].", sold: ".$cars[1][2].".<br>";
echo $cars[2][0].": In stock: ".$cars[2][1].", sold: ".$cars[2][2].".<br>";
echo $cars[3][0].": In stock: ".$cars[3][1].", sold: ".$cars[3][2].".<br>";
?>
我尝试了我的方法,但没有任何想法?方法:
$info = array
(
while($row = mysqli_fetch_array($retval, MYSQL_ASSOC))
{
array($row["id"],$row["name"],$row["mname"],$row["sdate"],$row["fdate"],$row["bphoto"],$row["sphoto"],
$row["text"],$row["one"],$row["two"],$row["three"],$row["four"],$row["five"],$row["six"],$row["seven"],
$row["eight"],$row["nine"],$row["imdb"],$row["sztrailer"],$row["etrailer"]),
}
);
查询:
document.getElementById("alcim").innerHTML = "(" + ' . $info[$_GET["list"]][2] . ' + " " + ' . $info[$_GET["list"]][3] . ' + "-" + ' . $info[$_GET["list"]][4] . ' + ")";
有什么想法吗? 如何编辑php矩阵值使用mysql?
答案 0 :(得分:0)
$info = array
(
while()[...]
那是错的。你不要把php命令放在一个数组中。你只将值放在数组中。试试这个:
$info = [];//prettier short-hand version of array()
while($row = mysqli_fetch_array($retval, MYSQL_ASSOC))
{
$info[] = $row; //append $row, which allready is an array containing all you want, to $info
}
那么你可以用循环输出你的$ info。