Home > Database > Mysql Tutorial > body text

PHP simple database operation

巴扎黑
Release: 2016-11-22 09:19:22
Original
1190 people have browsed it

//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]";
}

                                                                                                                                                                                              .

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template