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
  • 2
Random Affilaites
Topic Started: Jun 25 2005, 11:57 PM (1,129 Views)
FearKiller
Member Avatar
www.drewscripts.com
[ *  *  *  *  * ]
There were also some problems in my coding as well. I was unaware that array_rand() selected random keys rather than random values when selecting more than one entry in an array. Here is the corrected code.

Code:
 
<?php
$affs = array();
$affs[] = 'http://yahoo.com http://img.photobucket.com/albums/v469/khubsuratgraphics/KGAffiliate3.gif';
$affs[] = 'http://yahoo.com http://sinionkabe.itopsites.com/button.php?id=8165';
$affs[] = 'http://yahoo.com http://www.banditsplace.net/topsites/button.php?id=94';
$affs[] = 'http://yahoo.com http://img.photobucket.com/albums/v113/Bolesroor/banditsplace.gif';
$affs[] = 'http://yahoo.com http://img.photobucket.com/albums/v444/teentalkcentral/Affiliate.gif';
$affs[] = 'http://yahoo.com http://i4.ifrm.com/1567/154/upload/p1915011.gif';
$affs[] = 'http://yahoo.com http://img.photobucket.com/albums/v673/charlieschill/p6272124.gif';
$affs[] = 'http://yahoo.com http://www.pixel2life.com/images/banners/mbanner2.gif';

$rand_img = array_rand($affs, 5);

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


I also forgot to end the anchor element in the last code as well. :$

EDIT: Changed $imgs to $affs. Thanks Qj for pointing out that mistake.
Offline Profile Quote Post Goto Top
 
Jory
Member Avatar
Member
[ *  *  *  *  *  * ]
Qj
June 29, 2005 06:10 PM
Try changing
Quote:
 
$rand_img = array_rand($imgs, 5);
to
Quote:
 
$rand_img = array_rand($affs, 5);

Still need to do that <_<

now, array_rand() attempts to get 5 keys/values from the array $imgs, but there is no such array. Its all in $affs.

Offline Profile Quote Post Goto Top
 
commander-ZNS
Member
[ *  *  *  * ]
Cool it worked now but it didn't work the way I wanted it. Ok first of all check out how it looks here http://www.k-gfx.zerax.net/index.php. See how it is set up so all of them are on top of each other in a line. I don't want it like that. I want it like the picture below where the table is set up so it is 3 row and 2 colums. If than is not possible I can also make an affialite were it says VIEW ALL and it take you to the main affialite page so like the APPLY now and VIEW ALL are next to each orther and the RANDOM affialites is even number .

Offline Profile Quote Post Goto Top
 
mathiaus
Member Avatar
mathiaus maximus™
[ *  *  *  *  *  * ]
which code are you now using?
Offline Profile Quote Post Goto Top
 
commander-ZNS
Member
[ *  *  *  * ]
This one that FearKiller posted above on the 2nd page.

Code:
 
<?php
$affs = array();
$affs[] = 'http://yahoo.com http://img.photobucket.com/albums/v469/khubsuratgraphics/KGAffiliate3.gif';
$affs[] = 'http://yahoo.com http://sinionkabe.itopsites.com/button.php?id=8165';
$affs[] = 'http://yahoo.com http://www.banditsplace.net/topsites/button.php?id=94';
$affs[] = 'http://yahoo.com http://img.photobucket.com/albums/v113/Bolesroor/banditsplace.gif';
$affs[] = 'http://yahoo.com http://img.photobucket.com/albums/v444/teentalkcentral/Affiliate.gif';
$affs[] = 'http://yahoo.com http://i4.ifrm.com/1567/154/upload/p1915011.gif';
$affs[] = 'http://yahoo.com http://img.photobucket.com/albums/v673/charlieschill/p6272124.gif';
$affs[] = 'http://yahoo.com http://www.pixel2life.com/images/banners/mbanner2.gif';

$rand_img = array_rand($affs, 5);

foreach($rand_img as $img_value) {
$linkimg = explode(' ', $affs[$img_value]);
echo '<a href="', $linkimg[0], '"><img src="', $linkimg[1], '" alt="', $linkimg[0], "\" /></a>\n";
}
?>
Offline Profile Quote Post Goto Top
 
Jory
Member Avatar
Member
[ *  *  *  *  *  * ]
Just change the last part a bit:

Quote:
 

$td = 0
echo "<tr>\n";
foreach($rand_img as $img_value) {
$linkimg = explode(' ', $affs[$img_value]);
echo '<td><a href="', $linkimg[0], '"><img src="', $linkimg[1], '" alt="', $linkimg[0], "\" /></a><td>\n";
$td++
if($td == 2)
{
echo "</tr>\n<tr>\n";
$td = 0;
}
}
echo "</tr>\n";
?>


I think this would do it.

Edit:
This is the part that comes AFTER
Quote:
 
$rand_img = array_rand($affs, 5);
:)
Offline Profile Quote Post Goto Top
 
FearKiller
Member Avatar
www.drewscripts.com
[ *  *  *  *  * ]
That opening table column tag after the end anchor tag should be a closing table column tag. So that line should look like this.
Code:
 
echo '<td><a href="', $linkimg[0], '"><img src="', $linkimg[1], '" alt="', $linkimg[0], "\" /></a></td>\n";


You could also probably get away with just increasing the width of the main affiliates column so that the images have enough space to fit and won't wrap to the next line.
Offline Profile Quote Post Goto Top
 
commander-ZNS
Member
[ *  *  *  * ]
FearKiller
July 1, 2005 10:37 AM
That opening table column tag after the end anchor tag should be a closing table column tag. So that line should look like this.
Code:
 
echo '<td><a href="', $linkimg[0], '"><img src="', $linkimg[1], '" alt="', $linkimg[0], "\" /></a></td>\n";


You could also probably get away with just increasing the width of the main affiliates column so that the images have enough space to fit and won't wrap to the next line.

Ok I am totally confused about what you said. I dont know anything about coding. So can you please edit the code and give me the new one. Also is it possible to remove that blue border around the affialite?
Offline Profile Quote Post Goto Top
 
FearKiller
Member Avatar
www.drewscripts.com
[ *  *  *  *  * ]
After
Code:
 
<style type="text/css">
<!--

in your HTML coding add these following lines.

Code:
 
.style4 {display: block; width: 190px;}
a img {border-width: 0;}


That should give you the appearance of two columns and remove the blue border around the images. If you still see only one column, edit line 1 above where it says "width: 190px" and increase the width from 190px to like 195px or 200px etc. and your going to want to use the original code for this and not the editted version Qj created above as that will put each of your images in a table column.

As always I suggest using proper and up to date code. I suggest you validate your coding and convert to CSS positioned DIVs rather than table based layouts in the future.
Offline Profile Quote Post Goto Top
 
Jory
Member Avatar
Member
[ *  *  *  *  *  * ]
FearKiller
July 1, 2005 04:37 PM
That opening table column tag after the end anchor tag should be a closing table column tag.

:$
Silly me.

And what is wrong with putting them in different table cels?

Oh, as for the blue border, change
Quote:
 
<a href="', $linkimg[0], '"><img src="', $linkimg[1], '" alt="', $linkimg[0], "\" /></a>

To
Quote:
 
<a href="', $linkimg[0], '"><img src="', $linkimg[1], '" alt="', $linkimg[0],  "\"  border="0" /></a>
Offline Profile Quote Post Goto Top
 
commander-ZNS
Member
[ *  *  *  * ]
I did what FearKiller said and it wokred great. But there is one more problem. Just look at my site http://www.k-gfx.zerax.net/index.php . Do you see how those affialites are touching the border on the left. How do I make them go a little bit to the right so its in the middle. I tried to align it to center but it doesn't working.
Offline Profile Quote Post Goto Top
 
Jory
Member Avatar
Member
[ *  *  *  *  *  * ]
Quote:
 
.style4 {display: block; width: 190px; text-align: center;}


That should do it.
Otherwise, try
Quote:
 
.style4 {display: block; width: 190px; padding: 2px;}

(Though the first would look better and just is, really.)
Offline Profile Quote Post Goto Top
 
commander-ZNS
Member
[ *  *  *  * ]
It worked but still not perfect. Anyway to fix it? http://www.k-gfx.zerax.net/index.php

I used this

Code:
 
<style type="text/css">
<!--
.style4 {display: block; width: 190px; padding: 2px;}
a img {border-width: 0;}
</style>
Offline Profile Quote Post Goto Top
 
mathiaus
Member Avatar
mathiaus maximus™
[ *  *  *  *  *  * ]
the width is wrong. The cell its in is only 180px wide!
<td width="180" valign="top">
so changing it to 180 or under and then centering everything?


EDIT: just checked witht he edit css tool for firefox (very handy) the below should be used!

Code:
 
<style type="text/css">
<!--
.style4 {display: block; width: 180px; padding: 1px;}
a img {border-width: 0}
</style>


Offline Profile Quote Post Goto Top
 
commander-ZNS
Member
[ *  *  *  * ]
wow worked perfectly

Iwould like to thank each and everyone that helped.
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
  • 2