Reputation: 80
We have saved lots of images in uploads folder in root folder. But we want to display only a single image for each user profile.
The name of the image is stored in database table user
in the field profile_image
. Now using this name I need to retrieve the same name image from uploads folder.
<?php
$filename=mysql_query("SELECT profile_image FROM user WHERE username='$user_check'");
?>
<div id="photo">
<?php
echo "<img src='uploads/".$filename."' class='img'/>";
?>
</div>
Upvotes: 0
Views: 869
Reputation: 357
$result = $mysqli->query("SELECT profile_image FROM user WHERE username='$user_check'" LIMIT 1");
while ($row = mysqli_fetch_assoc($result)){
$filename=$row['profile_image'];
}
<div id="photo">
<?php
echo "<img src='uploads/".$filename."' class='img'/>";
?>
</div>
you can use mysql and not mysqli if you want
Upvotes: 2