PHP basic knowledge review. Header (Content-Type: texthtml; charsetUTF-8); $ connmysql_connect (localhost, root,); linked server (non-permanent) if (! $ Conn) {echohr; die (error:. mysql_error ();} el header ("Content-Type: text/html; charset = UTF-8 ");
$ Conn = mysql_connect ('localhost', 'root', ''); // link server (non-permanent)
If (! $ Conn ){
Echo' ';
Die ('Error: '. mysql_error ());
} Else {
Echo' ';
Echo 'linked server: '. $ conn;
}
$ Db = mysql_select_db ('test', $ conn); // select a database
If (! $ Db ){
Echo' ';
Die ('Error: '. mysql_error ());
} Else {
Echo' ';
Echo 'link database: '. $ db;
}
/*
Mysql_query () only returns a resource identifier for SELECT, SHOW, EXPLAIN or DESCRIBE statements. if the query execution is incorrect, FALSE is returned.
For other types of SQL statements, if mysql_query () is executed successfully, TRUE is returned. If an error occurs, FALSE is returned.
If the return value is not FALSE, the query is legal and can be executed by the server. This does not indicate any affected or returned number of rows. It is very likely that a query is successfully executed but does not affect or no rows are returned.
*/
$ SQL = "SELECT * FROM user ";
$ Result = mysql_query ($ SQL, $ conn); // executes a MySQL Query. this function automatically reads and caches the record set. To run a non-cache query, use mysql_unbuffered_query ().
Echo' ';
Echo 'query result set: '. $ result; // The Resource identifier returned.
// Echo' ';
// Print_r (mysql_fetch_array ($ result, MYSQL_ASSOC); // The function retrieves a row from the result set as the associated array
// Echo' ';
// Print_r (mysql_fetch_array ($ result, MYSQL_NUM); // The function retrieves a row from the result set as a numeric array
// Echo' ';
// Print_r (mysql_fetch_array ($ result); // The function retrieves a row from the result set as the associated array and number array. the mysql_fetch_row () function retrieves a row from the result set as the number array.
/*
The mysql_fetch_array () function retrieves a row from the result set as an associated array, or an array of numbers, or both.
Returns the array generated based on the rows obtained from the result set. If no more rows exist, false is returned.
*/
Echo' ';
Echo'
';While ($ row = mysql_fetch_array ($ result )){Echo"
";Echo"
". $ Row ['firstname']." | ";Echo"
". $ Row ['lastname']." | ";Echo"
". $ Row ['age']." | ";Echo"
". $ Row ['Hometown ']." | ";Echo"
". $ Row ['job']." | ";Echo"
";}Echo'
';
Echo' ';
Echo 'close a non-persistent MySQL connection: '. mysql_close ();
$ Name = array ('Fruits '=> array ('Orange', 'banana ', 'apple '),
'Veggi' => array ('carrot', 'colard', 'pea '));;
Echo' ';
Print_r ($ name ['Fruits '] [1]);
Echo' ';
Echo count ($ name); // calculates the number of units in the array or the number of attributes in the object.
Echo' ';
/*
The symbol "->" indicates the function and member variable of the call class.
*/
Class className {
Function funName (){
Echo "dggdgdgd ";
}
}
$ ClassOne = new className ();
$ ClassOne-> funName ();
Echo' ';
$ I = 0;
Do {
$ I ++;
Echo "The number is". $ I ."
";
}
While ($ I <5 );
Http://www.bkjia.com/PHPjc/325737.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/325737.htmlTechArticleheader ("Content-Type: text/html; charset = UTF-8"); $ conn = mysql_connect ('localhost', 'root ',''); // link the server (non-permanent) if (! $ Conn) {echo 'HR/'; die ('Error:'. mysql_error ();} el...