| | |
How to randomize links without repeating them ?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Hello, my site sees a lot of visits to the first page after the "cover", but very few beyond that page. I want to randomize the first inward link, and keep track, so if the reader decides to click "next", it won't load the same page. How do I do this, an external php script? (I've not done one of those yet.)
Thanks, and Season's Greetings
Jess
Thanks, and Season's Greetings
Jess
•
•
•
•
I get that, but I don't want any redundancy in the links. Your suggestion might offer the same page twice or more times in a row.
eg:
PHP Syntax (Toggle Plain Text)
// links array $links = array(...); // get users visited links to an array $visited_links = explode('|', $_SESSION['visited_links']); // remove visited links from links array foreach($visited_links as $visited_link) { unset($links[array_search($visited_link, $links)]); } // get a random link from unvisited links $link = $links[rand(0, count($links)-1)]; // add the selected link to visited array $visited_links[] = $link; // save visited links to user session as | separated string $_SESSION['visited_links'] = implode('|', $visited_links);
Last edited by digital-ether; Dec 28th, 2007 at 12:51 am.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
![]() |
Other Threads in the PHP Forum
- Previous Thread: A simple PHP question
- Next Thread: PHP search option remove
| Thread Tools | Search this Thread |
# 5.2.10 action address apache api array auto autoincrement beginner binary broken cakephp checkbox class classes cms code cron curl database date dehasher destroy display dissertation domain dynamic echo echo$_get[x]changingitintovariable... email error errorlog fatalerror file files folder form forms function functions google href htaccess html if-else image images include insert ip javascript joomla legislation limit link load login mail masterthesis menu mlm multiple mysql mysqlquery oop open paypal pdf persist php popup problem query radio random record recursion remote script search server sessions sms sockets source space sql syntax system table tutorial update upload url validator variable video web youtube







Exactly !