1)Á¬½Ó£º&conn=mysql_connect(¡°localhost¡±, ¡°joeuser¡±, ¡°somepass¡±);
2)¹Ø±ÕÁ¬½Ó£ºmysql_close($conn);
3£© Êý¾Ý¿âÓëÁ¬½Ó½¨Á¢ÁªÏµ£ºmysql_select_db(database name, connection index);
4£© ½«SQLÓï¾ä¸øMySQLÖ´ÐУº$result = mysql_query($sql, $conn); //Ôöɾ¸Ä²é¶¼ÊÇÕâ¾ä
5£© ¼ìË÷Êý¾Ý£º·µ»Ø¼Ç¼Êý£º$number_of_rows = mysql_num_rows($result);
½«¼Ç¼·ÅÈëÊý×飺$newArray = mysql_fetch_array($result);
Àý×Ó£º
1: < php
2: // open the connection
3: $conn = mysql_connect(¡°localhost¡±, ¡°joeuser¡±, ¡°somepass¡±);
4: // pick the database to use
5: mysql_select_db(¡°testDB¡±,$conn);
6: // create the SQL statement
7: $sql = ¡°SELECT * FROM testTable¡±;
8: // execute the SQL statement
9: $result = mysql_query($sql, $conn) or die(mysql_error());
10: //go through each row in the result set and display data
11: while ($newArray = mysql_fetch_array($result)) {
12: // give a name to the fields
13: $id = $newArray['id'];
14: $testField = $newArray['testField'];
15: //echo the results onscreen
16: echo ¡°The ID is $id and the text is $testField
¡±;
17: }
18: >