10 Day Learn PHP fifth day _php Tutorial

Source: Internet
Author: User
Tags learn php
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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.