Php and mysql are prime combinations. now let's talk about how to query mysql database records in php. the Function mysql_connectmysql_querymysql_select_dbmysql... php and mysql are prime combinations. now let's talk about the implementation of querying mysql database records in php. the Function mysql_connect mysql_query mysql_select_db mysql_fetch_array is mainly used. The following describes the implementation.
Www. phprm. comn "; echo" name: ". $ rows [name]; echo"
N "; echo" sex: ". $ rows [sex]; echo"
N "; echo" birthday: ". $ rows [birthday]; echo"
N "; echo" address: ". $ rows [address]; echo"N ";} // release the result set mysql_free_result ($ result); // query the condition $ query =" select * from friends where id = 1 "; // define SQL $ result = mysql_query ($ query); // send the SQL query echo mysql_result ($ result, 0, "name"); // output the name result echo"
"; Echo mysql_result ($ result, 0," birthday "); // output the birthday result echo"
"; Echo mysql_result ($ result, 0," sex "); // output sex result echo"
"; Echo mysql_result ($ result, 0," address "); // output address results // related operations $ conn = mysql_connect ('localhost', 'root ', ''); // open the connection $ fields = mysql_list_fields (" test "," friends ", $ conn ); // list the information of the test database friends table $ cols = mysql_num_fields ($ fields); // Obtain the number of results for ($ I = 0; $ I <$ cols; $ I ++) // loop {echo mysql_field_name ($ fields, $ I ). "n"; // output field name echo"
";}
Summary: It is quite simple and common to query database records in php. you can query data as long as you record the above functions.
Address:
Reprinted at will, but please attach the article address :-)