Lydia Richardson Lydia Richardson - 9 days ago 5
MySQL Question

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

When using CSS for my DetailsTable the information I am getting from the database is not being displayed correctly in the table. All of that information is getting bunched up together and therefore isn't being laid out as a table.

If anyone could suggest why the information I am trying to get isn't being laid out in a table form that would be much appreciated

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




The CSS code is below.

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

Answer

You have closed the</table> tag before the php code, that maybe the problem

Comments