Really go into the database for the first time

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.