2016-11-24 50 views
1

對我的DetailsTable使用CSS時,我從數據庫中獲取的信息在表格中沒有正確顯示。所有這些信息都聚集在一起,因此不能作爲桌面佈局。數據庫信息不在表格中排隊(php/sql)

如果有人可以說明爲什麼我想要得到的信息不被在將不勝感激表格形式佈局

</head> 
<body> 
<div id="DetailsTable" > 
    <table> 
     <tr> 
      <th>Name</th> 
      <th>TypeOfShoe</th> 
      <th>Description</th> 
      <th>Price(£)</th> 
      <th>Fabric</th> 
      <th>Colour</th> 
      <th>Brand</th> 

     </tr> 
    </table> 
    <?php 
    $shoesID=$_GET['id']; 

    $stmt = $conn->prepare("SELECT shoes.name, shoes.images, shoes.description, shoes.price, types.typeOfShoe, types.fabric, types.colour, brands.name AS bname FROM shoes INNER JOIN types on types.types_id = shoes.type_id INNER JOIN brands on brands.brands_id = shoes.brands_id 
    WHERE shoes.id = :id"); 

    $stmt->bindValue(':id',$shoesID); 
    $stmt->execute(); 

    if ($shoes=$stmt->fetch()){ 
     echo "<td>".$shoes['name']."</td>"; 
     echo "<td>".$shoes['typeOfShoe']."</td>"; 
     echo "<td>".$shoes['description']."</td>"; 
     echo "<td>".$shoes['price']."</td>"; 
     echo "<td>".$shoes['fabric']."</td>"; 
     echo "<td>".$shoes['colour']."</td>"; 
     echo "<td>".$shoes['bname']."</td>"; 
    } 

    $conn=NULL; 
    ?> 
    <br> <br/> 
    <div id="Image" > 
     <img src="<?php echo $shoes['images']; ?>" height="500px" width="500px" /> 
    </div> 
</div> 

的CSS代碼如下。

body { 
background-color: lemonchiffon; 
}   

#DetailsTable { 

border-collapse: collapse; 
width: 100%; 
} 

th, td { 
text-align: left; 
padding: 8px; 
} 



#Image{ 
display: block; 
margin: auto; 
width: 50%; 
height: 10px; 
clear: both; 
} 

回答

0

你的PHP代碼之前關閉</table>標籤,也許問題

0
</head> 
<body> 
<div id="DetailsTable" > 
    <table> 
     <tr> 
      <th>Name</th> 
      <th>TypeOfShoe</th> 
      <th>Description</th> 
      <th>Price(£)</th> 
      <th>Fabric</th> 
      <th>Colour</th> 
      <th>Brand</th> 

     </tr> 
    <?php 
    $shoesID=$_GET['id']; 

    $stmt = $conn->prepare("SELECT shoes.name, shoes.images, shoes.description, shoes.price, types.typeOfShoe, types.fabric, types.colour, brands.name AS bname FROM shoes INNER JOIN types on types.types_id = shoes.type_id INNER JOIN brands on brands.brands_id = shoes.brands_id 
    WHERE shoes.id = :id"); 

    $stmt->bindValue(':id',$shoesID); 
    $stmt->execute(); 

    if ($shoes=$stmt->fetch()){ 
    echo '<tr>'; 
     echo "<td>".$shoes['name']."</td>"; 
     echo "<td>".$shoes['typeOfShoe']."</td>"; 
     echo "<td>".$shoes['description']."</td>"; 
     echo "<td>".$shoes['price']."</td>"; 
     echo "<td>".$shoes['fabric']."</td>"; 
     echo "<td>".$shoes['colour']."</td>"; 
     echo "<td>".$shoes['bname']."</td>"; 
    echo '</tr>'; 
    } 

    $conn=NULL; 
    ?> 
    </html> 
    <br> <br/> 
    <div id="Image" > 
     <img src="<?php echo $shoes['images']; ?>" height="500px" width="500px" /> 
    </div> 
</div>