1
Poslanik
Random image + link generator.
  • 2005/11/13 11:59

  • Poslanik

  • Just popping in

  • Posts: 95

  • Since: 2005/2/11


Ok, I'll have to admit this really doesn't have much with xoops. But since there are a lot of coders hanging out here I though I'd post this none the less.

I need a php script that will randomly load an image from a directory and add a link to it. All images are the same size, same format and each image needs to have a specific link so when the script randomly loads an image it will always have the same link I set to it. Oh and I should be able to upload new images to the folder without changing the code but it's not a must. I don't mind modifying some code once a week or so.

Why do I need this? Because I need a block in which this script will randomly load my site's offers and each offer will have a link attached to it. The principle upon it works is the same as random screenshots scripts you can find all over the internet. The only different is that when I click on the image I don't see a full version of it (because random screenshots are actually thumbnails of the actual screenshots) but instead I visit another page (it's a link after all).

I would appreciate it a lot if someone helped me.

2
carnuke
Re: Random image + link generator.
  • 2005/11/13 13:12

  • carnuke

  • Home away from home

  • Posts: 1955

  • Since: 2003/11/5


a search on google for php script random "image with link" came up with this

link

Here's the code, but I would check the link above as well for a demo
<html>
<
head>
<
title></title>
</
head>
<
body>
<
script language="javascript">
<!--
var 
b1dis "<a href="";
var bdis = ""><img src="";
var edis = " 
width="110" height="100" alt="some text" border="0"></a>";
var rnumb = "";
var img = "";

rnumb += Math.floor(Math.random()*3);
img = rnumb;

if (img == "
0") {
document.write(b1dis+ "
page1.html" +bdis+ "images/page1.gif"" +edis);
}

if (
img == "1") {
document.write(b1dis"page2.html" +bdis"images/page2.gif"" +edis);
}

if (img == "
2") {
document.write(b1dis+ "
page3.html" +bdis+ "images/page3.gif"" +edis);
}

// -->
</script>
</
body>
</
html>


Here's another script
http://houseofstrauss.co.uk Resource for alternative health and holistic lifestyle
search xoops

3
carnuke
Re: Random image + link generator.
  • 2005/11/13 13:20

  • carnuke

  • Home away from home

  • Posts: 1955

  • Since: 2003/11/5


If you get this working, perhaps you would be kind enough to post a FAQ with details

Thanks.
http://houseofstrauss.co.uk Resource for alternative health and holistic lifestyle
search xoops

4
Poslanik
Re: Random image + link generator.
  • 2005/11/14 9:52

  • Poslanik

  • Just popping in

  • Posts: 95

  • Since: 2005/2/11


It's javascript but I think I can handle it. Thanks.

Can you just tell me where in the script (first one, link to second isn't working) is the image folder declared?

5
Poslanik
Re: Random image + link generator.
  • 2005/12/8 14:50

  • Poslanik

  • Just popping in

  • Posts: 95

  • Since: 2005/2/11


Well no need to answer my previous post.

The first script which you posted works great! It's easy to modify, and it's not PHP what's more important :)

Thanks a lot mate.

Login

Who's Online

129 user(s) are online (67 user(s) are browsing Support Forums)


Members: 0


Guests: 129


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits