我有这段代码可以从数据库中选择和输出数据
<?php
require('system/connect.php'); //load the connection file
$sql = ("SELECT * FROM `movie`"); // add mysql code to a variable. In this case it will select ALL columns from the database.
$query = mysql_query($sql); //run the query contained within the variable.
while ($row = mysql_fetch_array($query)) { //store each single row from the database in an array named $row. While there are any rows left, loop through and execute the following code:
$id = $row['movie_id']; //gets name from DB for a single row
$name = $row['movie_name']; //gets age from DB for a single row
$category = $row['movie_category']; //gets age from DB for a single row
//Following code outputs the data to the webpage:
echo $id;
echo $name;
echo $category;
};
?>
页面显示:1titanicromance2zoroaction3blood diamondsaction
我需要一种方法来制作表格或数组并将数据直接插入其中。