Images from a database
The code generated by Ultradev does noet support images that are stored in the database. Ultradev requires that you store your images on your webserver and then link to them from your database. This is how you can do that:
Firstly create your database with all necessary field headings and formats. Instead of calling the sound and image formats OLE you should make the image field a text field in your database. Then put the path to the image which will be created. I.E. myImage.jpg or or www.mywebsite.com/images/myImage.jpg, so the location where the image is being put in your site map.
In your asp page you should build a recordset that contains the database field that refers to the image. To make a dynamic image select Insert > Image from the menu, or insert an image using the objects panel. In the Select Image Source dialog box choose Select File Name From: Data Sources and select the relevant database table containing the referrer to the image. When you now preview the page (f.e. in Live Data mode) you should see your image.
It seems obvious but it can take a long time to work this out :-)
If you have any problems with this send some comments of the details of what you have done.
Also check out the following webpages for more information:
- www.macromedia.com/support/ultradev/content/dynamic_images/
- Blob tutorial (how to store images in your database): www.ultradevextensions.com/blob/
Comments
Building further on this...
Using this same technique you could draw your links, emailaddresses, dates, ALL types of form objects and about everything else that has a folder icon OR a Lightning bolt next to it.
But since this is a FAQ about images...
Let's add a random selection to the image and supply it with a extra "URL" field in the database.
Now, project the dynamic image AND link reference into the page, like you would a normal image that links, but making both values dynamic.
Next, call up your Query, look at the SQL and wonder what would randomise the way it sorts them.
Done that ? You came up with something similar as this, right ?
SELECT * FROM RevenueMaker ORDER BY RAND();
RevenueMaker being my Banner table...We want to limit what it returns, so we add LIMIT 1; that makes:
SELECT * FROM RevenueMaker ORDER BY RAND() LIMIT 1;
This doesn't guarantee a 100% never twice the same banner in a row, but as your banner fields grow, the chances of the same one popping up twice in a row are severely reduced.
That is it, if you refresh the page that displays imagelinks like this you will see it changes. With a bit of thinking and a extra field we can also limit the time it is displayed and can make something up at certain dates, Like 14 days till halloween, 13 days till halloween, 12... 11, HURRY UP IT'S HALLOWEEN, HALLOWEEN, HALLOWEEN...
Silver Shamrock ;-)
Good luck and let me know if you make a millionaire with this small detail i wanted to share with you.
With regards,
Dennis van Galen
RE: Building further on this...
RE: Building further on this...
hi thanks for this nice tutorial but i have one question and maybe you guys can teach me how.. what if there will be no image for certain records? i get an "X" mark if there is no web address or path to that certain image.. how can i make it show another image instead of a bad link of the famouse X mark?..
thanks
You must me logged in to write a comment.