We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
  • Pages:
  • 1
Random Affialites
Topic Started: Jun 16 2005, 01:42 AM (896 Views)
commander-ZNS
Member Avatar
Member
[ *  *  *  * ]
Guys I need a script for my site http://www.k-gfx.zerax.net/index.php . So you see where it says BLAH BLAH BLAH. Ok over there I want 6 random affalites to show. 2 affialites will be on the top and 2 will be in the middle and the rest 2 will be on the bottom. Also out of those 6 random affililaites , always want 1 of them to always show. Like the last one. Meanng the affailtie row 3 column 2, there will be 5 affialtes for APPLY NOW in diffrent colors. So the row 3 column 2 affialie will always be the APPLY NOW affiliete and in random colors. So I have 5 diffrent images of APPLY NOW and they must show randomly in row 3 column 2.

Posted Image


Random Affilaites to Show in row 3 coloum 2.

Posted Image

Posted Image

Posted Image

Posted Image

Posted Image
Offline Profile Quote Post Goto Top
 
Jory
Member Avatar
Member
[ *  *  *  *  *  * ]
I don't really get the
Quote:
 
2 affialites will be on the top and 2 will be in the middle and the rest 2 will be on the bottom

Looking at the site, I'd say you just want them to be inside the box.


Quote:
 
Also out of those 6 random affililaites , always want 1 of them to always show

If it always shows, whats random about it?
Or do you mean "I always want one so show" ?

Quote:
 
Meanng the affailtie row 3 column 2, there will be 5 affialtes for APPLY NOW in diffrent colors. So the row 3 column 2 affialie will always be the APPLY NOW affiliete and in random colors. So I have 5 diffrent images of APPLY NOW and they must show randomly in row 3 column 2.


All I can make of this is that you have different picts for some them.


So In short: Make more sence (of hope somebody other then me comes along, understands it and is willing to help)


Oh, and is it me, or is that site showing F-up in FF but good in IE?
Offline Profile Quote Post Goto Top
 
commander-ZNS
Member Avatar
Member
[ *  *  *  * ]
Posted Image


Random Affilaites to Show in row 3 coloum 2.

Posted Image

Posted Image

Posted Image

Posted Image

Posted Image
Offline Profile Quote Post Goto Top
 
Jory
Member Avatar
Member
[ *  *  *  *  *  * ]
I see they are afflynowblue.gif(ex) in the dir images.
Ok, assuming the file is in the rootdir, you could use:
Quote:
 

<?php
// Putting all images in one array.
// Just ad images to it and they will be added to the cycle.
$affly = array("afflynowblue.gif","afflynowcyan.gif","afflynowgreen.gif","afflynowred.gif","afflynowyellow.gif");
// Finding out how many images you have in the array
$number = count($affly);
// Letting PHP select one of the files randomly
$imagenumber = rand(0,$number);
// I use 0 because PHP counting starts at 0, not 1. So the first image has the number 0.
$image = $affly['$imagenumber'];
?>
<img scr="images/<?php echo $image; ?>" alt="Affiliat for Apply Now">

Just put that in the place where you want to have the image.
(Of well, just the <img> line, the rest can be anywhere, as long as it is above the <img> line (Like in the <head>, thats where I put stuff like that most of the time.)


(This is if you have PHP enabled, what I do assume, looking at the URL you gave (the index.php mart mostly :P ) )

If this gives errors of some sort, please quote them here :)
I'll see where I went wrong.
Offline Profile Quote Post Goto Top
 
FearKiller
Member Avatar
www.drewscripts.com
[ *  *  *  *  * ]
Code:
 

$imgs = array();
$imgs[] = 'http://www.site.com img2.gif';
$imgs[] = 'http://www.site.com img2.gif';
$imgs[] = 'http://www.site.com img3.gif';
$imgs[] = 'http://www.site.com img4.gif';

$rand_img = array_rand($imgs, 2);

foreach($rand_img as $img_value) {
$linkimg = explode(' ', $img_value);
echo("<a href=\"$linkimg[0]\"><img src=\"$linkimg[1]\" alt=\"$linkimg[0]\" />");
}


Place all your images that you want to be selected in the array called $imgs. Then select as many images as you want from $imgs by changing the number in the array_rand() function. I used the number "2" in the above example. Finally the foreach loop will print the number of random images you have selected. The above example should print 2 random images that are within the array $imgs.

EDIT: EDITED TO ACHIEVE DESIRED AFFECT STATED BELOW. Not makin any guarantees, but that should work I guess. Just input the desired sites and images in the $imgs array seperated by a space.
Offline Profile Quote Post Goto Top
 
commander-ZNS
Member Avatar
Member
[ *  *  *  * ]
FearKiller
June 16, 2005 03:29 PM
Code:
 

$imgs = array();
$imgs[] = 'img1.gif';
$imgs[] = 'img2.gif';
$imgs[] = 'img3.gif';
$imgs[] = 'img4.gif';

$rand_img = array_rand($imgs, 2);

foreach($rand_img as $img_value) {
echo("<img src=\"$img_value\" alt=\"random image\" />");
}


Place all your images that you want to be selected in the array called $imgs. Then select as many images as you want from $imgs by changing the number in the array_rand() function. I used the number "2" in the above example. Finally the foreach loop will print the number of random images you have selected. The above example should print 2 random images that are within the array $imgs.

FearKiller- How do I link the images. And what about the last image for the APPLY NOW thing?

Qj- I don't understand how your thing works? What do i put the links and the images of the appliest. Where do i put the link and image of the APPLY NOW thing?
Offline Profile Quote Post Goto Top
 
Jory
Member Avatar
Member
[ *  *  *  *  *  * ]
The one FearKiller made is proably better.
Offline Profile Quote Post Goto Top
 
commander-ZNS
Member Avatar
Member
[ *  *  *  * ]
for the one that fear made. Whare do i put the links for the images?
Offline Profile Quote Post Goto Top
 
FearKiller
Member Avatar
www.drewscripts.com
[ *  *  *  *  * ]
Put them in the $imgs array. Say you wanted to link to invisionfree. Here's how you would do it.
Code:
 
$imgs[] = 'http://www.invisionfree.com ifimg.png';

Make sure you have a space between the link and the path to the image or it won't explode properly in the loop.
Offline Profile Quote Post Goto Top
 
Captain Kam
Custom member title
[ *  *  *  *  * ]
Just out of curiosity, may I use the blue "Apply Now" button for my own affiliation box? ^^'

Here's one I use for random images:

Place this in your <head> tags:
Code: HTML
 
<script type="javascript">var theImages = new Array()

// The Images
theImages[0] = 'http://k-gfx.zerax.net/images/afflynowblue.gif' // Blue "Apply Now" button
theImages[1] = 'http://k-gfx.zerax.net/images/afflynowcyan.gif' // Aqua "Apply Now" button
theImages[2] = 'http://k-gfx.zerax.net/images/afflynowgreen.gif' // Green "Apply Now" button
theImages[4] = 'http://k-gfx.zerax.net/images/afflynowred.gif' // Red "Apply Now" button
theImages[5] = 'http://k-gfx.zerax.net/images/afflynowyellow.gif' // Yellow "Apply Now" button

var j = 0
var p = theImages.length;
var preBuffer = new Array()

for (i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));

// Link URLs and Borders
function showImage(){
if(whichImage==0){
document.write('<a href ="http://k-gfx.zerax.net/YOURAFFILIATESPAGE.html"><img src="'+theImages[whichImage]+'" border=0 width=300 height=100></a>');
}
if(whichImage==1){
document.write('<a href ="http://k-gfx.zerax.net/YOURAFFILIATESPAGE.html"><img src="'+theImages[whichImage]+'" border=0 width=300 height=100></a>');
}
if(whichImage==2){
document.write('<a href ="http://k-gfx.zerax.net/YOURAFFILIATESPAGE.html"><img src="'+theImages[whichImage]+'" border=0 width=300 height=100></a>');
}
if(whichImage==3){
document.write('<a href ="http://k-gfx.zerax.net/YOURAFFILIATESPAGE.html"><img src="'+theImages[whichImage]+'" border=0 width=300 height=100></a>');
}
if(whichImage==4){
document.write('<a href ="http://k-gfx.zerax.net/YOURAFFILIATESPAGE.html"><img src="'+theImages[whichImage]+'" border=0 width=300 height=100></a>');
}
if(whichImage==5){
document.write('<a href ="http://k-gfx.zerax.net/YOURAFFILIATESPAGE.html"><img src="'+theImages[whichImage]+'" border=0 width=300 height=100></a>');
}

}
</script>


(NOTE: Please edit the following with your Apply Page)

Code: HTML
 
if(whichImage==5){
document.write('<a href ="http://k-gfx.zerax.net/YOURAFFILIATESPAGE.html"><img src="'+theImages[whichImage]+'" border=0 width=300 height=100></a>');
}


And then place the following where you want the random button at:
Code: HTML
 
<script>showImage();</script>


If there's something wrong with this code, it's prolly the <script> tags. o_O'


You're welcome in advance. o_o' I spent 10 minutes rewriting my code to fit yours.
Offline Profile Quote Post Goto Top
 
pingu2k4
Member
[ *  * ]
I would also like to have a random affilliates box, but 1 without pictures for them, where it shows a specified number of the affilliates. Say i had 3000 affilliates to show, but i only had room for 5, i would want it to show a different 5 websites each time.


(by the way, the thing about not having pictures might be making it harder, but im serious about that part)

so, what language would i use for starters?
Offline Profile Quote Post Goto Top
 
Jory
Member Avatar
Member
[ *  *  *  *  *  * ]
Well, for things like this, I'd say PHP.
JS can do it, but I just don't really like it :no:
(And compare the code FearKiller posted to the code Dark Kam posted.
10 lines <> about 30/40 (:unsure: ) And the more you ad, the worse that gets.
So PHP can do it much shorter to :) )

The no images is not a big deal.

Code: HTML
 
$ads = array();
$ads[] = 'http://website1.com%Text for website 1';
$ads[] = 'http://website2.com%Text for website 2';
//And so on. and so on.

$number_of_ad_options = count($ads);

for($i=0;$i<=4;$i++)
{
$ad = rand(0,$number_of_ad_options);
$adinfo = explode('%',$ads['$ad']);
echo '<a href=\"' . $adinfo[0] . '\" target=\"_BLANK\">' . $adinfo[1] . '</a><br />';
}


This would end up looking like:
Quote:
 

Just ad lines more
Quote:
 
$ads[] = 'http://website1.com%Text for website 1';
lines to it.
(For 3000 sites, this will be some work, but that can't be helped :no: (not by me anyway :P )
Offline Profile Quote Post Goto Top
 
pingu2k4
Member
[ *  * ]
Ok, and do i have to put a

<sript type =BLAH>

and

</script>


tag anywhere for tht? and what language is that?
Offline Profile Quote Post Goto Top
 
Luke6006
Member
[ *  *  *  *  *  *  * ]
Read the pinned topic.
Offline Profile Quote Post Goto Top
 
Jory
Member Avatar
Member
[ *  *  *  *  *  * ]
pingu2k4
June 21, 2005 08:46 PM
Ok, and do i have to put a
<sript type =BLAH>
and
</script>
tag anywhere for tht? and what language is that?

This is PHP.
start the code with <?php and end it with ?>
(So no <script> tags)
Just put the full code where at the place where the box is.

Luke2005
 
Read the pinned topic.

He couldn't use this for his forums, as IF does not allow you to put php in the boardwrappers or in any other place.
And all the topic really says is that you shouldn't post things relative to IF and that Seth fears Jeremy. :r
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · Technology Chat · Next Topic »
Add Reply
  • Pages:
  • 1