Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 12-13-2010, 07:22 PM Php Random Page
Novice Talker

Posts: 8
Name: Amar Chugg
Trades: 0
Can somebody help me find a script or a code that when clicked shoots to a random page of the site. I tried looking for it but i couldnt find it.

I used wibiya (toolbar) and they have a random posts button on the toolbar that does the same. I took off the toolbar and i need to figure out how to do it

Can somebody please help me.

Thank Youuuuuuu!

**

Alsoo, i dont have a specific page that i want it randomized to, i want it to be randomized to all of my domain.

Last edited by achugg; 12-13-2010 at 07:27 PM..
achugg is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-13-2010, 07:33 PM Re: Php Random Page
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
You need a way to determine which pages to include. If you have a sitemap you could use that. Once you have that the rest is simple:
PHP Code:
$pages//assume this is an array of all of the urls in the site

$key array_rand($pages1);

header('Location: ' $pages[$key]); 
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 12-13-2010, 07:44 PM Re: Php Random Page
Novice Talker

Posts: 8
Name: Amar Chugg
Trades: 0
Quote:
Originally Posted by NullPointer View Post
You need a way to determine which pages to include. If you have a sitemap you could use that. Once you have that the rest is simple:
Great! I have an Sitemap but i don't really understand how i would integrate that. Can you describe to me exactly?
achugg is offline
Reply With Quote
View Public Profile
 
Old 12-13-2010, 07:53 PM Re: Php Random Page
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
It depends on the format of your sitemap, using mine as an example:
PHP Code:
$data simplexml_load_file('http://tinsology.net/sitemap.xml');

$urls = array();

foreach(
$data->children() as $url)
    
$urls[] = (string) $url->loc;

$key array_rand($urls1); 

header('Location: ' $urls[$key]); 
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 12-13-2010, 07:59 PM Re: Php Random Page
Novice Talker

Posts: 8
Name: Amar Chugg
Trades: 0
Quote:
Originally Posted by NullPointer View Post
It depends on the format of your sitemap, using mine as an example:
So, for example my sitemap url is srt.im/sitemap.xml

Would i put the following in a php file?
PHP Code:
$data simplexml_load_file('http://srt.im/sitemap.xml');

$urls = array();

foreach(
$data->children() as $url)
    
$urls[] = (string) $url->loc;

$key array_rand($urls1); 

header('Location: ' $urls[$key]); 
And then link a href to that php file?
achugg is offline
Reply With Quote
View Public Profile
 
Old 12-13-2010, 08:17 PM Re: Php Random Page
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Yes that would work.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 12-13-2010, 10:41 PM Re: Php Random Page
Novice Talker

Posts: 8
Name: Amar Chugg
Trades: 0
Just tried it, it works beautifully. Thanks a lot Buddy!!
achugg is offline
Reply With Quote
View Public Profile
 
Old 12-14-2010, 12:08 AM Re: Php Random Page
Banned

Posts: 143
Name: maheshadodis
Location: USA
Trades: 0
Quote:
Originally Posted by NullPointer View Post
You need a way to determine which pages to include. If you have a sitemap you could use that. Once you have that the rest is simple:
PHP Code:
$pages//assume this is an array of all of the urls in the site

$key array_rand($pages1);

header('Location: ' $pages[$key]); 
Nice post i was also searching for this thanks keep it up
maheshadodis is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Php Random Page
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.62291 seconds with 12 queries