<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>
我的第一个php
</title>
<link href="css/style.css" rel="stylesheet"/>
</head>
<body>
<!--step1-->
<!--查询表内容-->
<?php $con = mysql_connect("localhost", "root", "123456");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
//设置数据的字符集utf-8 mysql_select_db 设置活动的 MySQL 数据库。 mysql_query 执行一条 MySQL 查询 mysql_fetch_array 从结果集中取得一行作为关联数组,或数字数组,或二者兼有
mysql_query("set names utf8");
$result = mysql_query("SELECT * FROM product");
echo "<ul>";
while ($row = mysql_fetch_array($result)) {
echo "<li>";
//echo $row['name'] . " " . $row['price'] . " " . $row['description'] . " " . $row['images'];
//echo "<br />";
echo "<img src='".$row['images']."'>" ;
echo "<h1>".$row['name']."</h1>" ;
echo "<p>".$row['price']."</p>" ;
echo "<p>".$row['description']."</p>" ;
echo "</li>";
}
echo "</ul>";
mysql_close($con);
?>
</body>
</html>
<!--
<li>
<img src="data:images/1.jpg">
<h1>u型枕</h1>
<p>价格:10元</p>
<p>可爱可爱可爱</p>
</li>
-->