Php + mysqli: the method for printing the information of a table in the database to a table, mysqli table. Php + mysqli: how to print a table information in the database to a table. mysqli table this article describes how php + mysqli implements a table information (including the header) in the database) print to php + mysqli to print a table information in the database to the table, mysqli table
This example describes how to print a table (including the table header) in a database using php + mysqli. Share it with you for your reference. The details are as follows:
This code will show you. Basic knowledge is required. The code is as follows:
The code is as follows:
<? Php
$ Mysqli = new MySQLi ("localhost", "root", "123456", "liuyan ");
If (! $ Mysqli ){
Die ($ mysqli-> error );
}
Function showTable ($ mysqli, $ table_name ){
$ SQL = "select * from $ table_name ";
$ Res = $ mysqli-> query ($ SQL );
// Obtain the total number of returned rows and columns
Echo "total:". $ res-> num_rows. "row; Total:". $ res-> field_count. "column. ";
// Retrieve the header --- retrieve from $ res
Echo"
";While ($ field = $ res-> fetch_field ()){Echo"
{$ Field-> name} | ";}Echo"
";// Cyclically retrieve dataWhile ($ row = $ res-> fetch_row ()){Echo"
";Foreach ($ row as $ value ){Echo"
$ Value | ";}Echo"
";}Echo"
";
$ Res-> free ();
}
ShowTable ($ mysqli, "news ");
?>
I hope this article will help you with php programming.
Examples in this article describes how to use php + mysqli to print a table information (including the header) in the database...