0

I have the image URL saved in my mySQL database.($imageid). How can I display images using their respective id? I want to display different images attached to different blog posts,as we see in regular blogs.

Thank you.

3
  • 3
    $pic = "<img src='".$row['row_in_question']."'>"; echo $pic; basically. Commented Mar 17, 2014 at 20:05
  • 1
    Hey,thanks,the solution was simple. All the answers provided here worked. Commented Mar 17, 2014 at 20:10
  • No problemo, anytime. Commented Mar 17, 2014 at 20:14

1 Answer 1

1

Unsure what stage you are, bit you need to query your 'table' for a single result, perhaps the ID? If the column was Imageid then you could display it like below in an array of results.

$con=mysqli_connect("localhost","user","pass","my_db");

$result = mysqli_query($con,"SELECT * FROM table");

while($row = mysqli_fetch_array($result))
  {
  echo '<img src="' . $row['Imageid']  . '">';
  }

mysqli_close($con);
Sign up to request clarification or add additional context in comments.

3 Comments

You would store an image URL in a column named Imageid?
Is that not what the OP has stated?
Yes I stored the image URL in a column named imageid.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.