I've got my query working, it brings me the results I expect, but one column is going to be images, and I'm unsure of the best way to go about displaying them.
Initially I used the below code to get my results, without worrying about the images.
<?php
#requires connect script - similar to include to avoid including security details
require 'connectscript.php';
#query
$sql = "SELECT * FROM products WHERE CategoryName = 'Surfboards'";
#result
$result = mysqli_query($dbc, $sql) or die ("Bad Query: $sql");
#Opening table
#while loop to bring all results
echo "<table border='2'>";
echo "<tr><td>ProductID</td><td>Name</td><td>Brand</td><td>Model</td>
<td>Board Length</td><td>Board Type</td><td>Colour</td><td>Image</td>
<td>UnitPrice</td></tr>";
while($row = mysqli_fetch_assoc($result)) {
echo "<tr>
<td>{$row['ProductID']}</td>
<td>{$row['Name']}</td>
<td>{$row['Brand']}</td>
<td>{$row['Model']}</td>
<td>{$row['BoardLength']}</td>
<td>{$row['BoardType']}</td>
<td>{$row['Colour']}</td>
<td style='width:200px; height: 100px; overflow-hidden;'>{$row['Image']}</td>
<td>{$row['UnitPrice']}</td>
</tr>";
}
echo"</table>"
?>
I've also adjusted the code slightly with an img src in there, and it presents the broken as if it's looking for an image, but can't find one.
while($row = mysqli_fetch_assoc($result)) {
echo "<tr>";
echo "<td>{$row['ProductID']}</td>";
echo "<td>{$row['Name']}</td>";
echo "<td>{$row['Brand']}</td>";
echo "<td>{$row['Model']}</td>";
echo "<td>{$row['BoardLength']}</td>";
echo "<td>{$row['BoardType']}</td>";
echo "<td>{$row['Colour']}</td>";
echo "<td style='width: 400px; height: 400px; overflow-hidden;'><img
src=images/{$row['Image']}</td>";
echo "<td>{$row['UnitPrice']}</td>";
echo "</tr>";
}
echo"</table>"
?>
The images are stored in an images folder, within the htdocs folder on my xampp installation. I've double checked the path. The data type us VARCHAR and i've tried with and without the extention.
Any Suggestions?
Thanks
Will