簡體   English   中英

從MySQL數據庫檢索條目時重復頁面設計

[英]Repeated page design when retrieving entry from MySQL database

我剛剛制作了一個PHP腳本來從數據庫中檢索條目。 當我從表中檢索條目時,頁面如下所示 重復下面的表頭和表格。 我需要幫助,謝謝。

這是我正在使用的整個代碼:

<?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>

您沒有使用</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. 缺少</head><body> and </body>
  2. 我建議如果您實際上不想重復使用<html> <head></head><body>在循環外使用。 循環是指while循環

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM