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 $row [' ID '];//get ID in line echo ' | "; echo "
"; echo $row [' username ']; echo " | "; echo "
"; echo $row [' Password ']; echo " | "; echo "
"; } 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.