I'm trying to display each specific image to display in PHP/HTML page, it's currently displaying all the pages but I would like it to only display one for whenever I type in the function.
My code:
<div class="ser-grid-list img_style">
<div class="gallery1">
</div>
</div>
<div class="ser-grid-list img_style">
<div class="gallery1">
</div>
</div>
<div class="ser-grid-list img_style">
<div class="gallery1">
</div>
</div>
<div class="ser-grid-list img_style">
<div class="gallery1">
<?php
$sql = "SELECT image FROM product"; //sql query
$result = mysql_query($sql) or die(mysql_error($connection));
while ($row = mysql_fetch_array($result)) //display the results
{
echo "<p><img src='../images/" . ($row['image']) . "'" . " " . " />";
}
?>
What its doing:
http://puu.sh/cCs29/6769667d43.jpg
What I'm wanting to make them do is align from left to right. It was working with Static images coming through html but I decided to use a database. This was it prior
http://puu.sh/cCs5g/919c0c8c57.jpg
Thanks!
Simply get the id of your image just like this one
$sql = "SELECT image FROM product where id=101";
This is the easiest one? Am i missing something?
<p>
is a block element, so it'll start and end with a new line. If you want to display them inline, try eliminating the <p>
tags surrounding the <img>
tags.
And as @CodeSlayer suggests, if you only want one single image returned, add a WHERE
clause to your query to fetch a specific image.