簡體   English   中英

沒有排在表中的數據庫信息(php / sql)

[英]Database information not lining up in a table (php/sql)

當我的DetailsTable使用CSS時,我從數據庫中獲取的信息未在表中正確顯示。 所有這些信息都聚集在一起,因此沒有作為一個表格。

如果有人能夠建議為什么我想要得到的信息沒有以表格形式列出,我將非常感激

</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;
}

您已經在PHP代碼之前關閉了</table >標記,這可能是問題所在

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

暫無
暫無

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

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