ÉèΪÊ×Ò³ ¼ÓÈëÊÕ²Ø

TOP

ÈçºÎÓÃPHPÁ¬½ÓMySQL
2014-11-24 01:43:26 ¡¾´ó ÖРС¡¿ ä¯ÀÀ:274´Î
Tags£ººÎÓà PHP Á¬½Ó MySQL

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: >


¡¾´ó ÖРС¡¿¡¾´òÓ¡¡¿ ¡¾·±Ìå¡¿¡¾Í¶¸å¡¿¡¾Êղء¿ ¡¾ÍƼö¡¿¡¾¾Ù±¨¡¿¡¾ÆÀÂÛ¡¿ ¡¾¹Ø±Õ¡¿ ¡¾·µ»Ø¶¥²¿¡¿
ÉÏһƪ£ºÏßÐαía¡¢bΪÁ½¸öÓÐÐòÉýÐòµÄÏßÐÎ.. ÏÂһƪ£ºÊý¾Ý¿âÂÒÂëµÄÔ­ÒòºÍ½â¾ö

×îÐÂÎÄÕÂ

ÈÈÃÅÎÄÕÂ

Hot ÎÄÕÂ

Python

C ÓïÑÔ

C++»ù´¡

´óÊý¾Ý»ù´¡

linux±à³Ì»ù´¡

C/C++ÃæÊÔÌâÄ¿