MySQL function collection in PHP

Source: Internet
Author: User

1.array mysql_fetch_assoc ( resource $result ) gets a row from the result set as an associative array

Description

returns an associative array of corresponding result sets, and continues to move the internal data pointer.

Parameters:result

The result set of the resource type. This result set is from a call to mysql_query ().

Instance:

<?PHP$conn= Mysql_connect ("localhost","Mysql_user","Mysql_password" ); if(!$conn) {echo"Unable to connect to DB:".mysql_error (); Exit;} if(! mysql_select_db ("Mydbname") {echo"Unable to select Mydbname:".mysql_error (); Exit;} $sql="SELECT ID as userid, fullname, userstatus from sometable WHERE userstatus = 1" ; $result= mysql_query ($sql ); if(!$result) {echo"Could not successfully run query ($sql) from DB:".mysql_error (); Exit;} if(Mysql_num_rows ($result) ==0) {echo"No rows found, nothing-to-print so am exiting" ; Exit;} // whileA row of dataexists, put that row in$rowAs an associative arrayNote:IfYou're expecting just one row, no need to use a loop//note:if your put extract ($row); inside the following loop, you'llThen create$userid,$fullname, and$userstatus  while($row= Mysql_fetch_assoc ($result) {echo$row["userid" ]; Echo$row["FullName" ]; Echo$row["UserStatus" ];} Mysql_free_result ($result ); ?>

MySQL function collection in PHP

Related Article

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.