Learning Purpose: Learn to read data
Take a look at two functions first:
1, mysql_query
Sends 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 the Link_identifier parameter is not specified, the program automatically looks for the most recently opened ID. The query query string is either True or False when it is UPDATE, INSERT, and DELETE, the queried string is SELECT to return a new ID value, when False is returned, it is not successful but no return value, but the query string 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. If result has no data, a value of false is returned.
See 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 the table user, which is similar to the one in ASP
<%
Exec= "SELECT * from User"
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open exec,conn,1,1
Do and not rs.eof
Response.Write "Username:" &rs ("username") & "
"
Rs.movenext
Loop
%>
Of course first to connect to the database, generally we require_once (' conn.php '), and conn.php inside is the last time that the connection database code.
A little two commands can complete the work of reading the data, today said the next time the addition of data to delete the modification.
http://www.bkjia.com/PHPjc/314899.html www.bkjia.com true http://www.bkjia.com/PHPjc/314899.html techarticle Learning Purpose: Learn to read data first see two functions: 1, mysql_query send out a query string. Syntax: int mysql_query (string query, int [link_identifier]); return value: Integer ...