-
-
//1, connect to the database - $conn = mysql_connect('127.0.0.1','root','root');
- if(!$conn){
- die("Connection failed".mysql_error);
- }
//2, select database
- mysql_select_db("test");
//3 , send the operation statement
- $sql="select * from user";
//4, receive the result
- $res=mysql_query($sql,$conn);
-
//5, traversal results
- while($row=mysql_fetch_row($res)){
- echo "
$row[0]--$row[1]--$row[2 ]";
- } // bbs.it-home.org
//6, close
- mysql_free_result($res);
- mysql_close($conn);
- ?>
-
Copy code
|