Wasted so long, finally began to really contact my SQL database, good fun ~ really interesting also, SQL statement pretty simple, simple operation is very good operation. As for the familiar depth, there is a long way to go ~ How to connect the database in PHP is not as complex as I once thought, but I am too lazy. Just put the code you've knocked out and make a souvenir. Today is tired, play Badminton said, four years did not hit the ~ sleep old ~ tomorrow to add. There are a lot of harvest to summarize it ~
<?php$link = mysql_connect (' localhost ', ' root ', ' 29151885 ');//Connect to Database Mysql_set_charset (' UTF8 ', $link), if (! $link) { Die ('!!!!!! '. Mysql_error ());} else echo ' good! '; $a =mysql_select_db (' test ');//Returns a Boolean value to select the appropriate database $sql = "Select Id,name,sex from test2 where ID < 7"; $res = mysql_query ($sql) ; The return resource type executes the SQL statement//var_dump ($res);//$row =mysql_fetch_row ($res);//Get a row from the result set as an enumerated array//$row =MYSQL_FETCH_ASSOC ($res); /Get a row from the result set as an associative array//var_dump ($row); while (list ($id, $name, $sex) =mysql_fetch_row ($res)) {echo ' {$id}----{$name}----{$sex} '; Echo ' ?>
Really go into the database for the first time