PHP MySQL additions and deletions to check the simple example _php example

Source: Internet
Author: User
Tags php mysql

mysql_connect () Connection database

MYSQL_SELECT_DB Select Database

MYSQL_FETCH_ASSOC () Get result set

mysql_query () Execute SQL statement

Examples are as follows:

 <?php $con = @mysql_connect (' localhost ', ' root ', ' root ');/Connect database mysql_select_db ('
  Test ', $con);//Select Database $userInfo =mysql_query ("SELECT * from User", $con);//Create SQL statement echo "<table>";
    while ($row =mysql_fetch_assoc ($userInfo))//Gets the data for each row of the result set {echo <tr>;
    echo "<td>";
    echo $row [' ID '];//gets the ID echo "</td>" in the row;
    echo "<td>";
    echo $row [' username '];
    echo "</td>";
    echo "<td>";
    echo $row [' Password '];
    echo "</td>";
  echo "</tr>";
  echo "</table>"; Mysql_free_result ($userInfo);//release result set Mysql_close ($con);
  Close database/*delete $d = @mysql_connect (' localhost ', ' root ', ' root ');
  mysql_select_db (' Test ', $d);
  mysql_query ("Delete from user where id=1", $d);
  Mysql_close ($d);
  * */*insert $i = @mysql_connect (' localhost ', ' root ', ' root ');
  mysql_select_db (' Test ', $i);
  mysql_query ("INSERT into User (Username,password) VALUES (' Ad ', ' ad ')", $i);
  Mysql_close ($i); *///update $u = @mysql_connect (' localhost ', ' root ', ' root ');
  mysql_select_db (' Test ', $u);
  mysql_query ("Update user set Username= ' AAA ' where Username= '", $u);
  echo "Update user set username= ' ax ' where id=2"; Mysql_close ($u); 

Above this php MySQL additions and deletions to check the simple example is a small series to share all the content, I hope to give you a reference, but also hope that we support the cloud habitat community.

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.