PHP query MySQL database complete code _php tutorial

Source: Internet
Author: User

PHP Query the full code of MySQL database


PHP Query The full code of the MySQL database, when used, please be careful to modify the connection statement in the user name and password.

$link = mysql_connect (' localhost ', ' root ', ' 123456 ')//Fire tips: Please change your username and password first
Or Die (' Could not connect: '. Mysql_error ());
mysql_select_db (' Ruida ') or Die (' Could not select database ');

Execute SQL Query
$query = ' SELECT * from product ';
$result = mysql_query ($query) or Die (' Query failed: '. mysql_error ());

Display results in HTML
echo "









\ n "; while ($line = Mysql_fetch_assoc ($result)) {echo \ t \ n "; foreach ($line as $col _value) {echo "\t\t \ n "; } echo "\ t \ n "; } echo "
$col _value
\ n ";
Releasing the result set
Mysql_free_result ($result);
Close Connection liehuo.org
Mysql_close ($link);
?>

http://www.bkjia.com/PHPjc/848319.html www.bkjia.com true http://www.bkjia.com/PHPjc/848319.html techarticle PHP query MySQL database complete code PHP query MySQL database complete code, when used, please be careful to modify the connection statement in the user name and password. php $link = mysql_connect (' Localho ...

  • 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.