Learning Goal: Learn to read data
Take a look at two functions first:
1, mysql_query
sends out a query string. Grammar
: int mysql_query (string query, int [link_identifier]); return value: Integer
This function sends out the query string for MySQL to do related processing or operation. If the Link_identifier parameter is not specified. The program will proactively look for the recently opened ID. It is possible to return true or FALSE when the query queries string is UPDATE, INSERT, and DELETE. The query string is SELECT to return the new ID value. When False is returned, it is not a successful run but no return value, but the queried string has an error.
2, Mysql_fetch_object return class data. Syntax: Object mysql_fetch_object (int result, int [Result_typ]); Return value: Class
This function is used to split query result results into class variables.
If result has no data, a value of false is returned.
look at a simple example:
$exec = "SELECT * from user";
$result =mysql_query ($exec);
While ($rs =mysql_fetch_object ($result))
{
echo "Username:". $rs->username. "\ n";
}
?>
of course. There is a username field in the table user. This is similar to ASP.
of course first to connect to the database, generally we require_once (' conn.php '), and conn.php This is used to connect to the database once said code.
Copyright notice: This article Bo Master original article. Blog, not reproduced without consent.
10 days to learn PHP fifth day