0

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]\"> ";
   }
4

3 Answers 3

4

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.

0
1

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

3
  • because there are 300 record Aug 1, 2013 at 9:28
  • And also I got downvote even...What is the reason can tell me..??
    – GautamD31
    Aug 1, 2013 at 9:32
  • yes it work, but if there a solution script ... i will use it Aug 1, 2013 at 9:40
0

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

2
  • @DonyAditya thanks. Why we getting downvote if my code is working Aug 1, 2013 at 9:45
  • the moderator will handle in that complain @sonusindhu
    – Olrac
    Aug 1, 2013 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.