10 Day Learn PHP fifth day

Source: Internet
Author: User
Tags learn php

Learning Goal: Learn to read data

Take a look at two functions first:
1, mysql_query
sends out a query string. Grammar
: 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 operation. If the Link_identifier parameter is not specified. The program will proactively look for the recently opened ID. It is possible to return true or FALSE when the query queries string is UPDATE, INSERT, and DELETE. The query string is SELECT to return the new ID value. When False is returned, it is not a successful run but no return value, but the queried string has an error.



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.

look at a simple example:
$exec = "SELECT * from user";
$result =mysql_query ($exec);
While ($rs =mysql_fetch_object ($result))
  { 
echo "Username:". $rs->username. "\ n";
  } 
?>
of course. There is a username field in the table user. This is similar to ASP.



of course first to connect to the database, generally we require_once (' conn.php '), and conn.php This is used to connect to the database once said code.

Copyright notice: This article Bo Master original article. Blog, not reproduced without consent.

10 days to learn PHP fifth day

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.