Develerux Memphis Develerux Memphis - 4 months ago 8
MySQL Question

How to edit php matrix use mysql. (Multiple variables)

Example:

<?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>";
?>


And i try my method but didn't worked any idea ? Method:

$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"]),
}
);


Query:

document.getElementById("alcim").innerHTML = "(" + ' . $info[$_GET["list"]][2] . ' + " " + ' . $info[$_GET["list"]][3] . ' + "-" + ' . $info[$_GET["list"]][4] . ' + ")";


Any idea ?
How to edit php matrix values use mysql ?

Answer
$info = array
(
    while()[...]

THAT is wrong. you don't put php-commands inside an array. you only put values inside an array. try this:

$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
}

THEN you can output your $info with a loop.