Home > Backend Development > PHP Tutorial > Complete code for querying MySQL database with PHP_PHP tutorial

Complete code for querying MySQL database with PHP_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:22:27
Original
1301 people have browsed it

The complete code of PHP querying MySQL database

The complete code of PHP querying 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 results using HTML
echo "

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/848319.htmlTechArticleThe complete code of PHP querying MySQL database PHP The complete code of querying MySQL database, please pay attention to modifying the connection statement when using it Username and password. ?php $link = mysql_connect('localho...
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