Learning Purpose: Learn to read data
Look at two functions first:
1, mysql_query
Send out a query string. Syntax: 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 execution. If you do not specify the Link_identifier parameter, the program automatically looks for the most recently opened ID. If the query string is UPDATE, INSERT, and DELETE, the return may be true or false, and the query's string is a SELECT that returns a new ID value, and when false, it is not a successful execution but no return value, but a string of queries that is wrong Miss.
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. Returns the value of False if result has no data.
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, there is a username field in table user, which is similar to the one in ASP
Of course we have to connect the database first, generally we require_once (' conn.php '), and Conn. PHP is the last time you said the code to connect to the database.
The small two commands can complete the work of reading the data, said here today the next time to say that the data added delete changes.