- $DB _host = "localhost";
- $DB _login = "root";
- $DB _password = "123456";
- $conn =mysql_connect ($DB _host, $DB _login, $DB _password);
Copy CodeMysql_data_seek move the internal query pointer to the query line syntax bool Mysql_data_seek (Resource Result_indetifier,int row_number) Example:
- $DB _host = "localhost";
- $DB _login = "root";
- $DB _password = "123456";
- $DB _name = "Flag";
- $conn =mysql_connect ($DB _host, $DB _login, $DB _password);
- mysql_select_db ($DB _name);
- $res =mysql_query ("SELECT * from PRODUCT");
- $row =mysql_fetch_array ($res);
- for ($i =0; $i < $num; $i + +)
- $row =mysql_fetch_array ($res);
- Mysql_data_seek ($res, 0);//move the pointer back to the first line of the query fruit
Copy CodeMysql_fetch_array The result of the query exists in the array (one record per array element) syntax array mysql_fetch_array (Resource Result[,int result_type]) Example:
- $DB _host = "localhost";
- $DB _login = "root";
- $DB _password = "123456";
- $DB _name = "Flag";
- $conn =mysql_connect ($DB _host, $DB _login, $DB _password);
- mysql_select_db ($DB _name);
- $res =mysql_query ("SELECT * from PRODUCT");
- $row =mysql_fetch_array ($res);
Copy CodeMysql_fetch_object gets a row of query results, and is stored as object type, with Mysql_fetch_array () using exactly the same method, except that mysql_fetch_object () can only get query results by field name Echo $ row->fieldname; Correct usage echo $row->0; Error Usage Syntax Object Mysql_fetch_object (resource result) Example:
- $DB _host = "localhost";
- $DB _login = "root";
- $DB _password = "123456";
- $DB _name = "Flag";
- $conn =mysql_connect ($DB _host, $DB _login, $DB _password);
- mysql_select_db ($DB _name);
- $res =mysql_query ("SELECT * from PRODUCT");
- $row = $mysql _fetch_object ($res);
- while ($row)
- {
- echo $row àp_id;
- echo $row Àp_name;
- }
Copy Codemysql_insert_id after adding a piece of information using the Insert command, you can take advantage of this function to get an example of the unique ID syntax int mysql_insert_id ([esource Link_identifier]) that just added the record:
- $DB _host = "localhost";
- $DB _login = "root";
- $DB _password = "123456";
- $DB _name = "Flag";
- $conn =mysql_connect ($DB _host, $DB _login, $DB _password);
- mysql_select_db ($DB _name);
- $SQLStr "INSERT into produce (p_id,p_name) VALUES (', ' PHP book ')";
- $res =mysql_query ($res);
- $p _id=mysql_insert_id ();
Copy CodeMysql_num_rows get query Results There are several lines of syntax int mysql_num_rows (resource result) Example:
- $DB _host = "localhost";
- $DB _login = "root";
- $DB _password = "123456";
- $DB _name = "Flag";
- $conn =mysql_connect ($DB _host, $DB _login, $DB _password);
- mysql_select_db ($DB _name);
- $res =mysql_query ("SELECT * from PRODUCT");
- $num =mysql_num_rows ($res);
Copy CodeMysql_query sends out an example of a SQL syntax query statement syntax resource mysql_query (string Query[,resource link_identifier]):
- $DB _host = "localhost";
- $DB _login = "root";
- $DB _password= "123456";
- $DB _name = "Flag";
- $conn =mysql_connect ($DB _host, $DB _login, $DB _password);
- mysql_select_db ($DB _name);
- $res =mysql_query ("SELECT * from PRODUCT");
Copy Codemysql_select_db Select the database name to access syntax bool mysql_select_db (string Database_name[,resource link_identifier]) Example:
- $DB _host = "localhost";
- $DB _login = "root";
- $DB _password = "123456";
- $DB _name = "Flag";
- $conn =mysql_connect ($DB _host, $DB _login, $DB _password);
- mysql_select_db ($DB _name);
Copy Code1 2 3 Next last page |