PHP read MySQL data

Source: Internet
Author: User

Method/Step
  1. Configure the database First:

    Define ("Db_host", "localhost"); // database address, typically localhost Define ("Db_user", "root"); // Database user name Define ("DB_PSW", ""); // Database Password Define ("db_db", "databasename"); // database to operate on

  2. Connection:

    $conn mysql_connect  die (' Failed to connect to database '. mysql_error);

  3. Select database:

    mysql_select_db (db_db,$conndie (' Select Database Failed ').  Mysql_error);

  4. Retrieving tables: (Fill in TableName yourself)

    $result mysql_query  die (' Something went wrong '. mysql_error);

  5.  

    Output retrieved:

     while  ( Span style= "COLOR: #800080" > $row  = mysql_fetch_row  ( $result   foreach  ( $row  as   $data  ) { echo   $data . '    ' 
  6. 6

    Finally, it will be closed:

    Mysql_free_result ($result); Mysql_close ($conn);

PHP read MySQL data

Related Article

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.