Learning Objective: To learn to read data
Look at the two functions:
1, mysql_query
Submit a query string. Grammar: int mysql_query (string query, int [link_identifier]); return value: integer
This function submit query string for MySQL related to the handling or implementation. If not specified link_identifier parameters, the program will automatically find the nearest open ID. When the query is a query string UPDATE, INSERT and DELETE, is likely to return to the true or false; SELECT query string is then returned to the new ID value, when returns false, is not without the return of the successful implementation of value, but for A string of errors.
2, mysql_fetch_object to return to categories of information. Grammar: object mysql_fetch_object (int result, int [result_typ]); return value: Class
This function will be used to query results result in the demolition to the variable category. If the result do not have the information, then returns false values.
Look at a simple example:
< »
$ exec = “select * from user”;
$ result = mysql_query ($ exec);
while ($ rs = mysql_fetch_object ($ result))
(
echo “username:”. $ rs-> username. “<br>”;
)
«>
Of course, the user in the form of a username field, which in similar 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 “)&”< br>”
rs.movenext
loop
%>
Of course, have to connect to database, and we typically require_once ( ‘conn.php’); conn.php and said there is a link on the database code.
Two small orders can read data completed the work of the next time that the data added to delete amended.