Php+mysqli implements the method of printing a table information in a database to a table, mysqli table _php Tutorial

Source: Internet
Author: User

Php+mysqli implements the method of printing a table information in a database to a table, mysqli table


The example in this paper describes how Php+mysqli implements a method of printing a table information in a database, including a header, to a table. Share to everyone for your reference. Specific as follows:

This piece of code will look. Need to learn basic knowledge. The code is as follows:
Copy the Code code 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);
Gets the total number of rows and columns returned
echo "Total:". $res->num_rows. " ". $res->field_count." Column. ";
Get header---removed from $res
echo "














"; while ($field = $res->fetch_field ()) {echo " ";} echo " "; Loop out data while ($row = $res->fetch_row ()) {echo " "; foreach ($row as $value) {echo ' "; } echo " "; } echo "
{$field->name}
$value
";
$res->free ();
}
Showtable ($mysqli, "News");
?>

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/949459.html www.bkjia.com true http://www.bkjia.com/PHPjc/949459.html techarticle Php+mysqli implements the method of printing a table information in a database to a table, MYSQLI table This article describes the PHP+MYSQLI implementation of the database in a table information (including the table header) to print to ...

  • 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.