Greenguy's Board


Go Back   Greenguy's Board > Programming & Scripting
Register FAQ Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 2006-01-09, 02:13 PM   #1
dunkin
Just because I don't care doesn't mean I don't understand!
 
dunkin's Avatar
 
Join Date: Feb 2004
Posts: 92
Hoping to find a random link script

Hello gang,
I am looking for a little script which will display random links. I am using the following java but it is to cluttered to use with anything over 3-4 links listed. Plus the java has to be used every place you want the link displayed on a page. Very messy indeed. Not real fond of java anyway. I am guessing there is a nice php script around somwhere but I haven't found one. I don't have much experience with php, but will hopefully be able to figure it out and install it ok.

Also, if the script can be adjusted to display a picture of the day (not random but from a numbered list for example) that would be great.

You can message me here or through email at: webmaster(at)dunkinsworld.com
I really appreciate any help with this one.
Thanks again,
Dunkin

<script language="JavaScript">
<!--


function random_content(){
var mycontent=new Array()
//specify random content below.
mycontent[1]='<a href="http://www.xxxxxx.com">link text here 1</a></font>'
mycontent[2]='<a href="http://www.xxxxxx.com">link text here 2</a></font>'
mycontent[3]='<a href="http://www.xxxxxx.com">link text here 3</a></font>'
mycontent[4]='<a href="http://www.xxxxxx.com">link text here 4</a></font>'


var ry=Math.floor(Math.random()*mycontent.length)
if (ry==0)
ry=1
document.write(mycontent[ry])
}
random_content()
//-->
</script>
dunkin is offline   Reply With Quote
Old 2006-01-09, 03:45 PM   #2
Halfdeck
You can now put whatever you want in this space :)
 
Halfdeck's Avatar
 
Join Date: Oct 2004
Location: New Haven, CT
Posts: 985
Send a message via ICQ to Halfdeck
Top of the page (before any HTML):

PHP Code:
<?php

function random_link() {
   
$links = array("teen link" => "http://link1.com""mature babes" => "link2.com","horny sluts" => "link3.com");
   
shuffle($links); // randomize
   
list($linktext$url) = each($links); // pull the first link on the list
   
echo "<a href='$url'>$linktext</a>"// display it
}

?>
Then use <? random_link(); ?> in your HTML where ever you want the link displayed.

P.S. I'm not sure how random the shuffle() function is.

You can also create a random_link.php file, dump the code in there, then do an include where you want the link displayed:

<? include('path to file..../random_link.php'); ?>

Personally though, I would stick with JS, because with PHP you're adding a slight load on the server. Also, I'm sure you can use an external JS file and just call the function in your HTML. Only time I'd use PHP for something like this is if I was dealing with hundreds of links.
__________________
Success is going from failure to failure without a loss of enthusiasm.
Halfdeck is offline   Reply With Quote
Old 2006-01-10, 08:46 PM   #3
dunkin
Just because I don't care doesn't mean I don't understand!
 
dunkin's Avatar
 
Join Date: Feb 2004
Posts: 92
Thanks Halfdeck

Hey Halfdeck, thanks for your reply. You were right suggesting using java. I was able to adapt the script to use as an external .js. Works the same as php and much easier to set up. Took all of 2 minutes. I set it up with php but wasn't happy with the results. Too much of a pain for the little bit I need it.

Thanks again,
Dunkin
dunkin is offline   Reply With Quote
Old 2006-01-11, 06:39 AM   #4
Halfdeck
You can now put whatever you want in this space :)
 
Halfdeck's Avatar
 
Join Date: Oct 2004
Location: New Haven, CT
Posts: 985
Send a message via ICQ to Halfdeck
Np Dunkin
__________________
Success is going from failure to failure without a loss of enthusiasm.
Halfdeck is offline   Reply With Quote
Old 2006-01-12, 10:14 AM   #5
oast
With $10,000, we'd be millionaires! We could buy all kinds of useful things like ... love!
 
oast's Avatar
 
Join Date: May 2004
Location: UK
Posts: 316
I use a PHP include when I want a list of random links

My random.php is

Code:
<?php
$codes=array(
array('http://www.paysite.com?with&tracking&id','http://www.paysite.com/','PaySite Name'),
array('http://www.paysite2.com?with&tracking&id','http://www.paysite2.com/','PaySite2 Name'),
array('http://www.paysite3.com?with&tracking&id','http://www.paysite3.com/','PaySite3 Name'),
);
shuffle($codes);
$i=0;
if(!isset($number))
$number=5;
while(list(,$code)=each($codes)){
	if($i>=$number){break;}
	echo '<a href="'.$code[0].'" title="'.$code[2].'" onmouseover="window.status=\''.$code[1].'\';return true" onmouseoout="window.status=\'\';return true">'.$code[2]."</a><br />\n";
	$i++;
}
?>
The actual scripts I use have 80+ links in them.
I have different scripts for different niches. (rand-amateur.php, rand-bbw.php, rand-fetish.php, etc)

Where-ever I want 5 random links I call
Code:
<?php
include('/home/path/to/random.php');
?>
If I want more than 5 links (to fill a column for example) I set the $number variable before the include()
Code:
<?php
$number=12;
include('/home/path/to/random.php');
?>
Just another person's take on a similar topic...
__________________
Playboy Webmasters - The name says it all! $35 per signup or 60% revshare.
oast is offline   Reply With Quote
Old 2006-01-12, 10:30 AM   #6
Halfdeck
You can now put whatever you want in this space :)
 
Halfdeck's Avatar
 
Join Date: Oct 2004
Location: New Haven, CT
Posts: 985
Send a message via ICQ to Halfdeck
Hi oast,

I have a script similar to that also. My script deals with over 3000 links. When I used to run an include I'd write something along the lines of:

<?php

require_once("/configfile");
$links = new links(15, "amateur sites");

$links->draw();
?>

But now I'm trying to avoid dynamicly generating those, unless absolutely necessary.
__________________
Success is going from failure to failure without a loss of enthusiasm.
Halfdeck is offline   Reply With Quote
Old 2006-01-12, 03:00 PM   #7
oast
With $10,000, we'd be millionaires! We could buy all kinds of useful things like ... love!
 
oast's Avatar
 
Join Date: May 2004
Location: UK
Posts: 316
I use similar functions on some of my TGPs, where I have one big file full of links with the niche type as part of the array and use a function call to decide on the niche table to draw.

<?php table(tranny,3); ?>

IMO, as with rotating banners; if there is a list (or table) of links, it is beneficial to have the appearance that the links are being 'updated' rather than seeing the same ones on each visit.. even if it is the same 10 displayed in a different order each time.
__________________
Playboy Webmasters - The name says it all! $35 per signup or 60% revshare.
oast is offline   Reply With Quote
Old 2006-01-12, 03:12 PM   #8
dunkin
Just because I don't care doesn't mean I don't understand!
 
dunkin's Avatar
 
Join Date: Feb 2004
Posts: 92
Hello Halfdeck and Oast, thank you both for the info.
I have one more question if you don't mind. Would you happened to know of a php code to show a picture of the day, not random. Show a new picture each day that would draw from a large list of pictures, say a years worth, 365?
Thanks again,
Dunkin
dunkin is offline   Reply With Quote
Old 2006-01-12, 04:31 PM   #9
oast
With $10,000, we'd be millionaires! We could buy all kinds of useful things like ... love!
 
oast's Avatar
 
Join Date: May 2004
Location: UK
Posts: 316
PHP has a lot of date related functions, so a list of 365 pictures could be put into an array and a key could be pulled out corresponding to the day of the year.
date(z); gives you a number from 0-365
http://www.php.net/date


Here is a simple POTD consisting of 365 images using seperate thumbnails and links to fullsize images
PHP Code:
<?php
$pics
=array(array('pic1','thumb1','Picture 1'),
array(
'pic2','thumb2','Picture 2'),
array(
'pic3','thumb3','Picture 3'),
array(
'pic4','thumb4','Picture 4'),
... 
etc
);
$today=date('z');
echo 
"<a href=\"{$pics[$today][0]}\"><img src=\"{$pics[$today][1]}\" alt=\"{$pics[$today][2]}\" border=\"0\" /></a><br />\n";
?>
Link to Picture is 1st part of array, then the URL of the thumbnail and finally the text for the alt tag.

HTH

Steve
__________________
Playboy Webmasters - The name says it all! $35 per signup or 60% revshare.

Last edited by oast; 2006-01-12 at 04:46 PM..
oast is offline   Reply With Quote
Old 2006-01-13, 03:12 AM   #10
Halfdeck
You can now put whatever you want in this space :)
 
Halfdeck's Avatar
 
Join Date: Oct 2004
Location: New Haven, CT
Posts: 985
Send a message via ICQ to Halfdeck
Quote:
Originally Posted by oast
IMO, as with rotating banners; if there is a list (or table) of links, it is beneficial to have the appearance that the links are being 'updated' rather than seeing the same ones on each visit.. even if it is the same 10 displayed in a different order each time.
I agree. For a list of links, it's not a bad idea. For some of my pages that make multiple MYSQL calls, I prefer pre-generating / caching the page for quicker page delivery.
__________________
Success is going from failure to failure without a loss of enthusiasm.
Halfdeck is offline   Reply With Quote
Old 2006-01-13, 08:04 AM   #11
oast
With $10,000, we'd be millionaires! We could buy all kinds of useful things like ... love!
 
oast's Avatar
 
Join Date: May 2004
Location: UK
Posts: 316
Quote:
Originally Posted by Halfdeck
For some of my pages that make multiple MYSQL calls, I prefer pre-generating / caching the page for quicker page delivery.
I have a couple of pre-made scripts that utilise cacheing, and have heard that it is a very good idea.

For my 'homemade' scripting purposes, I have the luxury of numerous MySQL servers, so I can seperate the tasks (i.e. ad server on one, links db on another, main content on yet another, etc).
With the speed of MySQL (2000 lines in 0.4 seconds), I don't think cacheing would make that much difference for my purposes.

Another alternative would be to include the MySQL content in an iframe, so the static sections can load independently around it.
__________________
Playboy Webmasters - The name says it all! $35 per signup or 60% revshare.
oast is offline   Reply With Quote
Old 2006-01-13, 10:35 AM   #12
dunkin
Just because I don't care doesn't mean I don't understand!
 
dunkin's Avatar
 
Join Date: Feb 2004
Posts: 92
Hey gang,
Well, I tried using the POTD php that oast provided but just couldnt get it working. I am sure I am missing something simple. Plugged in the info as oast suggested as follows:


<?php
$pics=array(array('http://www.mydomain.com/images/mypic1.jpg',''http://www.mydomain.com/images/mypic1thumb.jpg','mypic1 alt text'),
array('http://www.mydomain.com/images/mypic2.jpg','http://www.mydomain.com/images/mypic2thumb.jpg','mypic2 alt tex'),
array('http://www.mydomain.com/images/mypic3.jpg','http://www.mydomain.com/images/mypic3thumb.jpg','mypic3 alt tex'),
array('http://www.mydomain.com/images/mypic4.jpg','http://www.mydomain.com/images/mypic4thumb.jpg','mypic4 alt tex'),

);
$today=date('z');
echo "<a href=\"{$pics[$today][0]}\"><img src=\"{$pics[$today][1]}\" alt=\"{$pics[$today][2]}\" border=\"0\" /></a><br />\n";
?>


The above was saved as" potd1.php

Called it up on an index page with: <?php include("potd1.php"); ?>

I am only getting the "infamous" blank box with red X, and no alt text.

I actually only need this to show a full size pic and alt text. No need for the thumb array.
An example would be a text link "click here for picture of the day" and this would go to a page with the full size picture. I attempted to adjust the scrip to show just a full size picture and alt text but no luck with that either.

I am sure this is a fairly easy script, but I am not the best with php, still learning the basics here. I really appreciate all the help provided. I am sure I am just overlooking something simple here.

Again, thanks for the all the help.
Dunkin
dunkin is offline   Reply With Quote
Old 2006-01-13, 03:19 PM   #13
oast
With $10,000, we'd be millionaires! We could buy all kinds of useful things like ... love!
 
oast's Avatar
 
Join Date: May 2004
Location: UK
Posts: 316
Quote:
I am only getting the "infamous" blank box with red X, and no alt text.
How many pics did you have in the array? Don't forget today is the 13th day of the year so it will show the 13th picture in the array.

Also, you have an extra apostraphe in your first thumb url, this will cause an error.

To just show a pic on a page corresponding to the day of the year:
PHP Code:
<?php 
$pics
=array(
array(
'/images/mypic1.jpg','mypic1 alt text'), 
array(
'/images/mypic2.jpg','mypic2 alt text'), 
array(
'/images/mypic3.jpg','mypic3 alt text'), 
array(
'/images/mypic4.jpg','mypic4 alt text'), 

); 
$today=date('z'); // z gets the day of the year, so need 365 pictures in above array
echo "<img src=\"{$pics[$today][0]}\" alt=\"{$pics[$today][1]}\">"
?>
__________________
Playboy Webmasters - The name says it all! $35 per signup or 60% revshare.

Last edited by oast; 2006-01-13 at 03:26 PM..
oast is offline   Reply With Quote
Old 2006-01-13, 04:18 PM   #14
dunkin
Just because I don't care doesn't mean I don't understand!
 
dunkin's Avatar
 
Join Date: Feb 2004
Posts: 92
Hello Oast,
Success!!! I completely forgot the day was day 13 and only had 10 pictures in the script. I knew it was going to be something just that simple. I cant thank you enough for your help. Actually, I am a kind of glad that it didnt work right away. I really learned a lot by playing with the code, referring to your messages and reading a few tutorials while trying to figure it out. I hope I can return the favor sometime.
Again thanks,
Dunkin
dunkin is offline   Reply With Quote
Old 2006-01-13, 10:46 PM   #15
oast
With $10,000, we'd be millionaires! We could buy all kinds of useful things like ... love!
 
oast's Avatar
 
Join Date: May 2004
Location: UK
Posts: 316
Your welcome, Dunk

Quote:
Originally Posted by dunkin
... I hope I can return the favor sometime.
I'll think of something and let you know
__________________
Playboy Webmasters - The name says it all! $35 per signup or 60% revshare.
oast is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:07 PM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc