PHP4 and MySQL database operation functions (2) _ MySQL
Source: Internet
Author: User
5. database Record operation functions (5): 1. mysql_fetch_array () format: arraymysql_fetch_array (intquery); if execution is successful, an array is returned, which stores the value of the next record, if the execution fails, False is returned. The returned array can be expressed by subscript or field name. Example: $ querymysql_qu <5>. database record operation functions (5 ):
If the execution is successful, an array is returned. the array contains the value of the next record. if the execution fails, False is returned.
The returned array can be expressed by subscript or field name.
The function is basically the same as the mysql_fetch_array () function of 1. The difference is that mysql_fetch_row () can only be expressed as an array subscript.
1 array is returned successfully, and False is returned if the operation fails.
Example:
$ Query = mysql_query ($ SQL, $ connect );
While ($ row = mysql_fetch_row ($ query ))
{
Echo $ row [0]. "|". $ row [1]."
";
}
?>
Note: The mysql_fetch_row () function can only be represented by an array subscript and start from 0.
In addition, mysql_fetch_row () is faster than mysql_fetch_array () and reads data from the next row.
3. mysql_result ()
Format: int mysql_result (int query, int row, string filedname );
In mysql_result (), the row parameter must start from 0, and the filedname parameter must be a real field name, which cannot be expressed by subscript.
If the execution is successful, the value of the field retrieved from the database is returned. if the execution fails, the value of False is returned.
The specified field can be read cyclically. if the execution is successful, a value is returned in the form of an object. if the operation fails, a value of False is returned.
Note: After the mysql_fetch_object () function is successfully executed, one object is returned!
The procedure is as follows:
$ Object-> Field name
5. mysql_data_seek ()
Format: int mysql_data_seek (int row, int query );
Move the cursor to the specified row (row_number)
If the execution is successful, true value is returned. if the execution fails, False is returned.
This function can be used with mysql_fetch_array () or mysql_fetch_row (). after using the mysql_data_seek () function, you can use mysql_fetch_array () or mysql_fetch_row () function to display the specified row.
1. mysql_create_db ()
Format: int mysql_create_db (string database name, int link_identifier );
You can use the mysql_query () or mysql_db_query () function to create or delete a database.
However, we can use this function to create a database more conveniently.
If one true value is returned successfully, if one fails, one false is returned.
2. mysql_drop_db ()
Format: int mysql_drop_db (string database name, int link_identifier );
You can use a program to delete one database.
However, we can use this function to delete one database more conveniently.
If one true value is returned successfully, if one fails, one false is returned.
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.