Php + mysqli: how to print a table in the database to a table. mysqli table _ PHP Tutorial

Source: Internet
Author: User
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" ";}Echo" ";// Cyclically retrieve dataWhile ($ row = $ res-> fetch_row ()){Echo" ";Foreach ($ row as $ value ){Echo" ";}Echo" ";}Echo"
{$ Field-> name}
$ Value
";
$ 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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.