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.