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 "tt$col_value | n";
}
echo "t
n";
}
echo "
n";
// Release the result set
mysql_free_result($result);
// Close the connection Liehuo.Org
mysql_close($link);
?>
http://www.bkjia.com/PHPjc/848319.htmlwww.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...