Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Displaying images that match database records

 
shuzo monsoon
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created a page which allows users to select a radio button which takes them to a page which displays details of the particular record they have selected. Though I can get the specific details of that record from the database I would like to be able to get a corresponding image for that record also. Can anyone think of a way which I can assign indexes for a particular record to an image? I have tried using an if-else loop to see what the id for the chosen record is and then tried to display the appropriate image, but this doesn't work.
Any help would be much appreciated!
 
Oliver Moore
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your image names correspond to the index number of your record, why not use something like:
<img src="/images/<%= indexNumber %>.jpg">
on the page where you are displaying the record the users has selected.
Obviously, there are a number of ways you can pull the index number from the record set you return rather than <%= indexNumber %>.
If your image name does not correspond to the index number, why not just store the file name of the image you want associated with the record in the database. You can the use the stored filename in a similar way to the above example.
Hope this is of help...
 
shuzo monsoon
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That makes sense, thanks a lot Ols. The name of my images is not the same as the index numbers but I think I will make them the same and it just might work. Thanks again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic