Jump to content

Trying to show pictures of items with year and description and sold sign. It seems to work but shows pictures on the leftside of webpage instead of across the webpage


Recommended Posts

try {
echo "<br>";
foreach($dbh->query("SELECT * FROM test_shot WHERE sold=1 ORDER BY year ASC") as $row) {
	
						if($row['picture'] != "" && $row['picture'] != null)
						{
						echo "<div class='image-holder'><img src ='".$row['picture']."' width=300px /><br>";  
            			}
						if($row['year'] != "" && $row['year'] != null)
						{
							echo $row['year'];
						}
						if($row['description'] != "" && $row['description'] != null)
						{
							echo $row['description'];
						}
						if($row['sold'] == 1) {
							echo "<img src='images/sold1.png'><br>";//Add your image code here
							}
							elseif ($row['sold'] == 0) {
							
							echo "</div><br>";
						}
					}

	}	

catch (PDOException $e) {
  print $e->getMessage();
}

?>

 

Link to post
Share on other sites

Thanks for the comment. I finally figured it out.

try {
echo "<br>";
foreach($dbh->query("SELECT * FROM test_shot WHERE testshot=1 ORDER BY year ASC") as $row) {
							
			echo "<div class='image-holder'><img src ='".$row['picture']."' width=300px /><br><a> ".$row['year']."  ".$row['description']."	</a>";
                      
            if($row['sold'] == 1) {
			echo "<img src='images/sold1.png'></div>";
			}
			elseif ($row['sold'] == 0) {							
			echo "</div>";
			}
		}
	}	

catch (PDOException $e) {
  print $e->getMessage();
}

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.