我正在尝试使用 php 从 mysql 数据库中检索数据并将该数据写入 html 网页。但我看到的都是空白,它什么也没写,我找不到错误在哪里。我更改了 localhost phpMyadmin 的密码,所以不会出错。我也没有收到任何“无法连接到数据库”错误。
这是我的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Kaç Yakıyor?</title>
<style type="text/css">
body
{
background-color:#CCC;
}
h1.header
{
font-family:"Courier New", Courier, monospace;
font-size:45px;
font-style:oblique;
font-weight:400;
text-align:center;
}
div.content
{
margin-top:100px;
margin-left:auto;
margin-right:auto;
width:61%;
background-color:#F00;
}
div.vehicles
{
margin-top:100px;
width:17%;
height:200px;
background-color:#0F6;
float:left;
}
</style>
</head>
<body>
<?php
mysql_connect("localhost","root","123123") or die(mysql_error());
mysql_select_db("kacyakiyor") or die(mysql_error());
$query = "SELECT marka from arabalar";
$result = mysql_query($query);
if($result){
while($row = mysql_fetch_array($result)){
?>
<h1 class="header">KAÇ YAKIYOR</h1>
<hr width="500px"/>
<div class="vehicles">
<h2><strong><em>Araba</em></strong></h2><hr/><br/>
<?php echo "$row['marka']"; ?>
<h2><strong><em>Motosiklet</em></strong></h2><hr/><br/></div>
<div class="content">asdfasfda
</div>
<?php
}
}
mysql_close();
?>
</body>
</html>