PHP is a server scripting language for creating a dynamic web page. As ASP and ColdFusion, users can mix
Learning purpose: learn to read data
See two functions first:
1, MySQL_Query
Send a query string. Syntax: int mysql_query (string query, int [link_identifier]); return value: integer
This function sends a Query string for mysql to do related processing or execution. If you do not specify a link_identifier parameter, the program automatically looks for the recently opened ID. When the Query query string is Update, Insert, and DELETE, the return may be true or false; the query string is SELECT that returns a new ID value, when returning false, not performing success but no return value, but The string of the query has an error.
2, MySQL_FETCH_Object Returns class information. Syntax: Object MySQL_FETCH_OBJECT (int result, int [result_typ]); return value: class
This function is used to remove the query results result in the class variable. If Result is not available, return false values.
Look at a simple example:
$ exec = "select * from user";
$ results = mysql_query ($ exec);
While ($ r = mysql_fetch_Object ($ result))
{
Echo "UserName:". $ r-> username. "
"
}
?>
Of course, there is a username field in the table User, which is similar to the ASP.
<%
EXEC = "Select * from user"
SET RS = Server.createObject ("AdoDb.Recordset")
Rs.Open Exec, CONN, 1, 1
Do While Not Rs.eof
Response.write "Username:" & RS ("UserName") & "
"
rs.movenext
loop
%>
Of course, you will first connect to the database, usually we require_once ('conn.php'); and Conn.php is the code that is last connected to the database.
A small two commands can complete the job of reading data, today, here, here, the next time the data is added to delete modifications.