How to use the mysqli_query () function in PHP
This article uses easy-to-understand examples to introduce how to use the mysqli_query () function in PHP, the content is very detailed, interested friends can refer to, hope to be helpful to you.
First, using PHP coding, I have the following mySQL table:
CREATE TABLE `students` (`ID` int (10) NOT NULL AUTO_INCREMENT, `Name` varchar (255) DEFAULT NULL, `Start` int (10) DEFAULT NULL, `End` int (10) DEFAULT NULL, PRIMARY KEY (`ID`)) ENGINE=InnoDB
Try to use the mysqli_query function in PHP to describe the table.
Code:
$link = mysqli_connect ($DB_HOST, $DB_USER, $DB_PASS, $DATABASE); $result = mysqli_query ($link, "DESCRIBE students")
The document says that for successful SELECT,SHOW,DESCRIBE or EXPLAIN queries, mysqli_query () will return
Mysqli_result object.
But from there I don't know how to print $result to display the query results. If possible, I'd like to print $result to make it look like:
+-+ | Field | Type | Null | Key | Default | Extra | +- +-+ | ID | int (10) | NO | PRI | NULL | auto_increment | | Name | varchar | YES | | NULL | | Start | int (10) | YES | | NULL | | End | int (10) | YES | | NULL | | +-+-+
Another problem I have is how to print the query SHOW CREATE TABLE students.
$result = mysqli_query ($link, "SHOW CREATE TABLE students"); on how to use the mysqli_query () function in PHP to share here, I hope the above content can be helpful to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.