How do i make a list that automatically changes order?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Seraphimk
Forum Newbie
Posts: 22
Joined: Mon Feb 09, 2009 12:49 pm

How do i make a list that automatically changes order?

Post by Seraphimk »

i want to make a list that lists a load of sites and that automatically changes the order the sites are shown without me having to do anything does anyone know of a script that can do this?
User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: How do i make a list that automatically changes order?

Post by greyhoundcode »

Change them in what way? Randomly?
Seraphimk
Forum Newbie
Posts: 22
Joined: Mon Feb 09, 2009 12:49 pm

Re: How do i make a list that automatically changes order?

Post by Seraphimk »

greyhoundcode wrote:Change them in what way? Randomly?
the order as in if there's a list of sites they just change the order they are seen
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: How do i make a list that automatically changes order?

Post by php_east »

shuffle
Seraphimk
Forum Newbie
Posts: 22
Joined: Mon Feb 09, 2009 12:49 pm

Re: How do i make a list that automatically changes order?

Post by Seraphimk »

php_east wrote:shuffle
yh i just don't know how to write a script that would shuffle them
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: How do i make a list that automatically changes order?

Post by php_east »

you don't have to, it's already written

( from PHP manual)
Description
bool shuffle ( array &array )
This function shuffles (randomizes the order of the elements in) an array.
Seraphimk
Forum Newbie
Posts: 22
Joined: Mon Feb 09, 2009 12:49 pm

Re: How do i make a list that automatically changes order?

Post by Seraphimk »

php_east wrote:you don't have to, it's already written

( from PHP manual)
Description
bool shuffle ( array &array )
This function shuffles (randomizes the order of the elements in) an array.
so what would i write im not that great at php so what would i write exactly?
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: How do i make a list that automatically changes order?

Post by php_east »

you would write an array consisting of a list of domains, and then you shuffle the array. that's it.
Seraphimk
Forum Newbie
Posts: 22
Joined: Mon Feb 09, 2009 12:49 pm

Re: How do i make a list that automatically changes order?

Post by Seraphimk »

php_east wrote:you would write an array consisting of a list of domains, and then you shuffle the array. that's it.
but i want to make the list within a table would i create a table then put the php code within it ?
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: How do i make a list that automatically changes order?

Post by php_east »

maybe not the entire table in php, you can use php just to generate just the list.

Code: Select all

<?php
$domains = Array();
$domains[] = 'http://www.google.com';
$domains[] = 'http://www.yahoo.com';
$domains[] = 'http://www.yuhuu.com';
:
:
:
 
shuffle($domains);
 
echo '<ul>';
foreach ($domains as $key=>$domain)
{ echo '<li><a href="'.$domain.'" >'.$domain.'</a><li>'; }
echo '</ul>';
Seraphimk
Forum Newbie
Posts: 22
Joined: Mon Feb 09, 2009 12:49 pm

Re: How do i make a list that automatically changes order?

Post by Seraphimk »

php_east wrote:maybe not the entire table in php, you can use php just to generate just the list.

Code: Select all

<?php
$domains = Array();
$domains[] = 'http://www.google.com';
$domains[] = 'http://www.yahoo.com';
$domains[] = 'http://www.yuhuu.com';
:
:
:
 
shuffle($domains);
 
echo '<ul>';
foreach ($domains as $key=>$domain)
{ echo '<li><a href="'.$domain.'" >'.$domain.'</a><li>'; }
echo '</ul>';
would i be able to put a time limit so it shuffles every 10 min or if i just put a meta refresh tag would that work?
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: How do i make a list that automatically changes order?

Post by php_east »

yes, sure.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: How do i make a list that automatically changes order?

Post by Chris Corbyn »

~ Seraphimk, the best way to learn is to take away the pointers people give you and to experiment with them before you ask further questions. There's nothing lost by just trying things to see what happens :)
Post Reply