PHP connects to mysql database demo

WBOY
Release: 2016-07-29 09:09:39
Original
1428 people have browsed it

$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.


Related labels:
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