Building further on this...

July 25, 2001 by Dennis van Galen

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...

July 25, 2001 by Waldo Smeets
Thank you very much for sharing your insight with us Dennis. I am looking forward to more of this usefull stuff. Thanks!

RE: Building further on this...

June 16, 2003 by lord hydra

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