Home  >  Article  >  Database  >  PHP simple database operation

PHP simple database operation

巴扎黑
巴扎黑Original
2016-11-22 09:19:221150browse

//1, connect to the database
$conn = mysql_connect('localhost','root','root');
if(!$conn){
die("Connection failed".mysql_error);
}

//2, select database
mysql_select_db("test");

//3, send operation statement
$sql="select * from user";

//4, receive results
$res= mysql_query($sql,$conn);

//5, traversal results
while($row=mysql_fetch_row($res)){
echo "
$row[0]--$row[1 ]--$row[2]";
}

                                                                                                                                                                                              .

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn