Ten days to learn the fifth day of php _ PHP Tutorial

Source: Internet
Author: User
The fifth day of learning php in ten days. Objective: to read data first, read two functions: 1. output a query string using mysql_query. Syntax: intmysql_query (stringquery, int [link_identifier]); return value: integer learning objective: to learn to read data

Let's first look at two functions:
1. mysql_query
Returns a query string. Syntax: int mysql_query (string query, int [link_identifier]); return value: integer

This function sends a query string for MySQL to perform related processing or execution. If the link_identifier parameter is not specified, the program automatically searches for the recently opened ID. If the query string is UPDATE, INSERT, or DELETE, the return value may be true or false. if the query string is SELECT, a new ID value is returned. if the return value is false, the query string is incorrect, instead of running successfully but without returning values.

2. mysql_fetch_object returns class data. Syntax: object mysql_fetch_object (int result, int [result_typ]); return value: Class

This function is used to split the query result into class variables. If the result contains no data, false is returned.

Let's 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, the table user has a username field, which is similar
<%
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 need to connect to the database first. generally, we require_once ('Conn. php'), while conn. php contains the code used to connect to the database.

Two small commands can be used to read data. today we will talk about how to add, delete, and modify data.

First, let's look at two functions: 1. mysql_query sends 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.