Common functions of data tables for beginners in PHP

mysql_query()

##mysql_query()

Associates with the specified connection identifierThe current number of activities in thedatabase sends aquery. Iflink_identifieris not specified, thelast opened connectionis used. If there is noopen connection, this method will try to call#mysql_connect()functionwithout parameters to establish it. Aconnect and use it. Query results will be cached.This function is used to execute sql statements

mysql_fetch_array()

Get a row from the result set as an association Array, or numeric array, or both

Returns an array generated based on the rows fetched from the result set, or false if there are no more rows

Syntax: mysql_fetch_array(data,array_type )

Detailed explanation: $sql = "sql statement";

$info = mysql_query($sql); //Execute sql statement

$row =mysql_fetch_array($info ); //Get the result set of sql

Print_r($row);

Example:

First we create a table in the database. The data table has id username password 3 fields, and then fill in some content

The code is as follows:QQ图片20161010113633.png

    数据表操作 查询 
"; print_r($row); echo "
"; } ?>

mysql_fetch_array() is an extended version of mysql_fetch_row(). In addition to storing data in an array as a numerical index, you can also store data as an associative index, using the field name as the key.

Tip: It is important to point out that using mysql_fetch_array() is not significantly slower than using mysql_fetch_row(), and it also obviously provides more values

## The #mysql_fetch_row() function obtains a row from the result set as a numeric array

##The code is as follows:

    数据表操作 查询 
"; print_r($row); echo "
"; } ?>

Note: mysql_fetch_row() obtains a row of data from the result set associated with the result identifier data and returns it as an array. Each result column is stored in a cell of the array, starting at offset 0.

Calling mysql_fetch_row() in sequence will return the next row in the result set, or FALSE if there are no more rows

##mysql_result() function

mysql_result() function returns the value of a field in the result set.

If successful, the function returns the field value. If it fails, return false

Syntax: mysql_result(data,row,field)

图片8.png

The code is as follows:

    数据表操作查询 


Continuing Learning
||
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!