Home > Backend Development > PHP Tutorial > PHP complete code to query MySQL database_PHP tutorial

PHP complete code to query MySQL database_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 14:54:33
Original
1180 people have browsed it

PHP The complete code for querying the MySQL database. Please pay attention to modifying the username and password in the connection statement when using it.

$link = mysql_connect('localhost', 'root', '123456') //Rainfire Tip: Please change the username and password first
or die('Could not connect: ' . mysql_error());
mysql_select_db('ruida') or die('Could not select database');

// Execute SQL query
$query = 'SELECT * FROM product' ;
$result = mysql_query($query) or die('Query failed: ' . mysql_error());

// Display the result in HTML
echo "

n";
while ($line = mysql_fetch_assoc($result)) {
echo "tn";
foreach ($line as $col_value) {
echo "ttn";
}
echo "
$col_value< ;/td>n";
}
echo "t
n";
// Release the result set
mysql_free_result($result);
// Close the connection Liehuo.Org
mysql_close($link);
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/364555.htmlTechArticlePHP The complete code for querying the MySQL database. Please pay attention to modifying the user name and password in the connection statement when using it. ?php $link = mysql_connect('localhost', 'root', '123456') //Fire Tip: Please...
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template