NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page Show X amount of random links w/o duplicates.

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search
6 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 09-10-2007, 11:24 AM THREAD STARTER               #1 (permalink)
Danltn.com
 
Daniel's Avatar
Join Date: May 2007
Location: Danltn.com / Nottingham, UK
Posts: 1,201
Daniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond repute
 


Ethan Allen Fund Ethan Allen Fund

Show X amount of random links w/o duplicates.


Hi there, this PHP script/snippet will show X amount of random links your site.

PHP Code:
 <?php

/*
 * Script written by Danltn
 * Leave this message intact for use, visitors won't see it, don't worry
 * URL: http://danltn.com
 */

function site($site$url
  {
  
// This function turns the provided parameters into a link.
    
$link '<a href="'$url '">' $site '</a>';
    return 
$link
  } 
 
// Set your websites here, remember to increase the number by one each time.
????: NamePros.com http://www.namepros.com/code/372434-show-x-amount-random-links-w.html

$website[1] = site("Google","http://google.com");
$website[2] = site("MSN","http://msn.com");
$website[3] = site("Yahoo","http://yahoo.com");
$website[4] = site("Ask","http://ask.com");
$website[5] = site("Ebay","http://ebay.com");

$before ""// What should go before each link, you could for example use it as a <li> element. I've set it to nothing.
????: NamePros.com http://www.namepros.com/showthread.php?t=372434
$after "<br />"// What should go after, it could be </li> or <br /> for example. I've set it to line break.

$show 3// Set the amount of websites to list here

// PHP Magic
$show floor($show);
if (
$show != 1) {
if (
$show count($website)) { $show count($website); }
$r array_rand($website$show);
for (
$k=0$k $show$k++)
{
echo 
$before $website[$r[$k]] . $after;
} } elseif (
$show 1) { $rand rand(1count($website)); echo $website[$rand]; }


?>
http://paste.biz/paste-2752.html

Enjoy.
Daniel is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 07:12 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger