Home >Backend Development >PHP Tutorial >PHP connects to mysql database demo

PHP connects to mysql database demo

WBOY
WBOYOriginal
2016-07-29 09:09:391446browse

$c "root", "password");
$result=mysql_db_query("Database", "SELECT * FROM `info`", $conn);
// Get query results
$row= mysql_fetch_row($result);


echo '';
echo '

';
/ / Display field name
              echo "
< td bgcolor="#000F00">'.
mysql_field_name($result, $i);
echo "
";
}
echo "
";
// Locate the first record
mysql_data_seek($result, 0);
// Loop through the records
while ($row=mysql_fetch_row($result))
{ & Echo "& LT; TR & GT; & LT;/B & GT;";
for ($ i = 0; $ i & lt; mysql_num_fields ($ result); $ i ++) {
echo '& lt; td bgcolor = " #00ff00 "& gt; ' ; lt ;/b>";
echo "
";
// Release resources
mysql_free_result($result);
// Close connection
mysql_close($conn);
?>


echo came out Mainly tables

The above introduces the PHP connection to mysql database demo, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.


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