Just back-end modify the page, do not need to display the front end can delete the original code only input <?php start writing language can, later? > Can omit
Build a connection
$connect = @mysql_connect("localhost", "root", "123");//The statement is the simplest made connection statement, too old for PHP5, will remind the statement will be eliminated, so need to suppress the reminder
Select the database to manipulate
mysql_select_db ("Ren", $connect);
Write SQL statements
$sql = "select * from course"; Read all the contents of the course table
Execute SQL statement, return result set
$result = mysql_query($sql);
Reading data from the result set
while ($attr = Mysql_fetch_row($result))//row is read in indexed array format, assoc is read in associative array format, and array is read in two array formats
{
Var_dump ($ATTR);
}
Chinese garbled solution: cause the encoding format is inconsistent
1. When creating a database, the character set selection Utf-8
2. Modify the MySQL configuration and add the Character_set_srever=utf8 below the [mysqld] Module
3. The encoding format of the modified page is Utf-8,header ("Content-type:text/html;charset=utf-8");
Add data
Build a connection
/* $connect = @mysql_connect ("localhost", "root", "123");
Select the database to manipulate
mysql_select_db ("HR", $connect);
Write SQL statements
$sql = "insert into nation values (' n006 ', ' Tibetan ')"; The added data must be added in a regular manner
Execute SQL statement, return result set
$result = mysql_query ($sql);
Reading data from the result set
Var_dump ($result); */result is ture, add success, if False, add failed
How to connect database basic statements in PHP