从MySQL数据库中检索条目时重复的页面设计

时间:2013-05-23 01:28:17

标签: php mysql

我刚刚创建了一个PHP脚本来从数据库中检索条目。当我从表中检索条目时,页面看起来像this。重复表格下面的标题和表格。我需要帮助,谢谢。

这是我正在使用的整个代码:

<?php
session_start();
include('connection.php');
$username='username';
mysql_query("SELECT * FROM regmember WHERE username='$username'");
$query=("SELECT * FROM product");
$result=mysql_query($query);
while($row=mysql_fetch_array($result))
{
?>

<html>
<head>
<link rel="stylesheet" type="text/css" href="index.css">
<title>Music Light</title>
<div align="center"><h1>Music Light</h1></div>
<div id="menu">
    <ul>
        <li><?php echo 'Welcome, '.$_SESSION['username']; ?></li>
        <li><a href="indexmember.php">Home</a></li>
        <li><a href="productmember.php">Product</a></li>
        <li><a href="profile.php">Profile</a></li>
        <li><a href="cart.php">Cart</a></li>
        <li><a href="testimony.php">Testimony</a></li>
        <li><a href="transaction.php">Transaction</a></li>
        <li><a href="logout.php">Logout</a></li>
    </ul>
</div>
<br>
<br>
<div align="center">
  <table border="0">
    <tr>
      <td>ID</td>
      <td></td>
      <td><?php echo $row[0];?></td>
    </tr>
    <tr>
      <td>Brand</td>
      <td></td>
      <td><?php echo $row[1];?></td>
    </tr>
    <tr>
      <td>Instrument Type</td>
      <td></td>
      <td><?php echo $row[2];?></td>
    </tr>
    <tr>
      <td>Price</td>
      <td></td>
      <td><?php echo $row[3];?></td>
    </tr>
    <tr>
      <td>Stock</td>
      <td></td>
      <td><?php echo $row[4];?></td>
    </tr>
    <tr>
      <td>Image</td>
      <td></td>
      <td><img height="150" width="150" src="productimg/<?php echo $row[6];?>"/></td>
  </table>
</div>
<div align="center">
<table>
<form name="deleteentry" action="delete.php" method="get">
    <tr>
        <td>Delete which entry? (enter product id)</td>
        <td><input type="text" name="delete"></td>
        <td><input type="button" name="deletebutton" value="Delete"></td>
    </tr>
</form>
</table>
</div>
<?php
}
?>
<br>
<br>
<div align="center"><p>Description template</p></div>
<footer>
  <p align="center">Copyright &copy; 2013 Music Light</p>
</footer>

2 个答案:

答案 0 :(得分:0)

您没有使用</head>

关闭标题
<head>
   <link rel="stylesheet" type="text/css" href="index.css">
   <title>Music Light</title>
</head>  <= Include this

  .
  .
  .
 </html> <= Include this as well at the end

答案 1 :(得分:0)

  1. 缺少</head><body> and </body>
  2. 如果您不想重复,我会建议在循环外使用<html> <head></head><body>。循环我的意思是while循环