PHP MySQL additions and deletions to the simple example _php instance

Source: Internet
Author: User
Tags php mysql
mysql_connect () connection Database

mysql_select_db Selecting a 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 "
 
 
  
  "; while ($row =mysql_fetch_assoc ($userInfo))//Get data for each row of the result set {echo '
  
  
     "; echo " 
    "; echo " 
    "; echo " 
    "; echo " 
   "; } echo " 
  
"; echo $row [' ID '];//get ID in line echo '"; echo $row [' username ']; echo ""; echo $row [' Password ']; echo "
"; 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= ' xx '", $u); echo "Update user set username= ' ax ' where id=2"; Mysql_close ($u);? >

The above this php MySQL additions and deletions to the simple example is the small part to share the whole content of everyone, hope to give you a reference, but also hope that we support the script home.

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