slice
slice

Reputation: 1

No images displayed on the page after querying the database PHP mysql

This is my first post on stackoverflow after following posts for a very long time. My problem is, I have a function that is supposed to retrieve data from a table (models) and display a name, location and an image to one of the pages. Everything is working but the images don't get displayed. Please look at my code and tell me what I should change to get these images to display. I'm using twitter bootstrap for styling. My directory is: localhost/mainsite/admin/uploads

I've checked everything related to this post and tried it out but they didn't solve my problem. So please help.

function view_models() {
	
	global $dbc;
	
	$q = "SELECT * FROM models";
	$r = mysqli_query($dbc, $q);
	
	while ($row = @ mysqli_fetch_array($r)) {
		
		$id = $row['model_id'];
		$mn = $row['model_name'];
		$ln = $row['location'];
		$img = $row['image1'];
		
		echo "
				<div class='col-xs-6 col-lg-3'>
									
					<h3>$mn</h3>
					<a href='details.php?id=$id'>									
					<img src='admin/uploads/$img' class='img-thumbnail' />
					<p>$ln</p>
										
				
				</div>";
		
	
		
		
	}

}

Upvotes: 0

Views: 35

Answers (1)

Sathish
Sathish

Reputation: 2460

Try this., I have changed the echo statement because you did a error, that was misplaced '&"

echo "<div class='col-xs-6 col-lg-3'>
      <h3>".$mn."</h3>
        <a href='details.php?id=".$id."'>                                   
          <img src='admin/uploads/".$img."' class='img-thumbnail' />
          <p>".$ln."</p>
        </a>                                    
    </div>";

Upvotes: 1

Related Questions