Reputation: 43
I want to ask.
I have table :
1. No = 01
2. ID = 001
3. Password = 001
4. IMAGE = 001
I save my images in folder Images.
If I have 100 record how i call image at database?? but I wont change my table at database
I can call my image when I change my data in table
1. No = 01
2. ID = 001
3. Password = 001
4. IMAGE = Images/001.jpg
Sample SCRIPT:
$user =$_SESSION['username'];
$data=mysql_query("select * from user WHERE ID=$user ");
while($baris=mysql_fetch_array($data))
{
echo "<img src=\"$baris[IMAGE]\"> ";
}
Upvotes: 0
Views: 3205
Reputation: 28763
Try like
echo "<img src='Images/".$baris['IMAGE'].".jpg'> ";
And if you have saved the folder name,then use
echo "<img src='".$baris['IMAGE'].".jpg'> ";
I did'nt understand why you are storing image name without extension
Upvotes: 1
Reputation: 1792
Try this
$user =$_SESSION['username'];
$data=mysql_query("select * from user WHERE ID=$user ");
while($baris=mysql_fetch_array($data))
{
echo "<img src='Images/".$baris[IMAGE].".jpg'> ";
}
Hope it will help
Upvotes: 0
Reputation: 8431
try to include in your path Images
folder and include the file extension '.jpg'
like:
$user =$_SESSION['username'];
$data=mysql_query("select * from user WHERE ID=$user ");
while($baris=mysql_fetch_array($data))
{
echo "<img src=\"Images/".$baris['IMAGE']."\">";
}
I strongly suggest that you also store the file extension (to handle .png,.gif and .jpeg
) and don't use mysql_*
instead use mysqli_*
or PDO
.
Upvotes: 4