SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Nov 2000
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Strange subject line I know!

    Here's what I was wondering. Go to http://www.DotDealers.com and look at how the domains are listed on the index page... "Category", "3 Domains", "More Domains". Is there a way to make those 3 Domains in each category randomly rotate on the index page using the rest of the domains in their respected category?

    I think it would be cool if everytime someone goes to the index page there are different domains listed in each category.

    I would just like to know if it can be done in PHP, and if so, is it really complicated.

    Thanks,

    Doug
    http://www.DotDealers.com

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It would be fairly easy I would generate three random numbers then use arrays to display the domain names.

    Like if you had an array of domain names for each category let's call htem $domains you could

    $domains = array("yo", "freddy", "sdsd", "dafedfg", "cindy", "bobby", "peter", "marsha", "greg", "jan", "mike", "carol", "alice", "astro");

    do {
    srand((double)microtime()*1000000);
    $randval = rand (0,(count($domains)));
    if (count($random) > 0) {
    if (!in_array($randval, $random)) {
    $random[] = $randval;
    }
    }
    else {
    $random[] = $randval;
    }
    }
    while(count($random) < 4);


    print $random[0]."<br>";
    print $random[1]."<br>";
    print $random[2]."<br>";

    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •