Objective: to learn to read data first read two functions before learning: 1. mysql_query sends a query string. Syntax: intmysql_query (stringquery, int [link_identifier]); return value: integer this function sends the query string for MySQL to do
Objective: to learn to read data
Before learning, let's first look at two functions:
1. mysql_query
Returns a query string. Syntax: int mysql_query (string query, int [link_identifier]); return value: integer
This function sends a query string for MySQL to perform coherent processing or fulfillment. If the link_identifier parameter is not specified, the program will take the initiative to find the latest opened ID. If the query string is UPDATE, INSERT, or DELETE, the return value may be true or false. if the query string is SELECT, a new ID value is returned. if the return value is false, the query string is incorrect instead of successfully executed but no return value.
2. mysql_fetch_object returns class material. Syntax: object mysql_fetch_object (int result, int [result_typ]); return value: Class
This function is used to split the query result into class variables. If the result has no material, false is returned.
Let's look at a simple example:
$ Exec = 'select * from user ';
$ Result = mysql_query ($ exec );
While ($ rs = mysql_fetch_object ($ result ))
{
Echo 'username: '. $ rs-> username .'
';
}
?>
Of course, the table user has a username field, which is similar
Of course, you need to connect to the database first. generally, we require_once ('Conn. php'), while conn. php contains the code used to connect to the database.
The preceding two commands can be used to read data. today we will talk about how to add, delete, and modify data.