PHP reads the MySQL content into a two-dimensional array and outputs it in the specified column
?
$host = "localhost"; Host Name
$user = "root"; MySQL User name
$password = ""; MySQL Password
$database = "Doc"; MySQL database name
$tables = "MClass"; Table name
$conn =mysql_connect ("$host", "$user", "$password") or Die ("Database open error");
mysql_select_db ("$database");
$query = "SELECT * from $tables";
$result =mysql_query ($query, $conn);
$i = 0;
$j = 0;
while ($row =mysql_fetch_row ($result)) {
$array [$i] [$j] = $row [0]. $row [1];
$array 2[$i] [$j] = $row [0];
$j + +; echo $i. ",". $j. $row [1]. "
";
if ($j ==3) {
$i + +;
$j = 0;
}//else {$j + +;}
}
$amax =count ($array);//is the number of data in the array.
$rows = 2; Set the number of columns
Start displaying data
For ($x =0 $x <= $amax-1; $x + +) {
for ($y =0; $y <= $rows; $y + +) {
echo " | ";
}
echo "
";
}
/*
Display results as
Aaa|bbb|ccc
Ddd|eee|fff
lll|mmm|nnn
.....
*/
? >