Results 1 to 2 of 2

Thread: Random data display

  1. #1
    Join Date
    Sep 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Random data display

    Hi every one,
    Please i need to some data from my database to display at a random for certain time, then refresh with another set of data.
    thanks, be
    very greatfull.

  2. #2
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    Here you go:

    PHP Code:
    <?php

    $arr 
    = array();

    $q mysql_query("SELECT * FROM mytable") or die(mysql_error());

    while(
    $r mysql_fetch_array$q )) {

    array_push($arr$r[myfieldvalue]);

    }
    shuffle($arr);

    echo 
    $arr[0];

    ?>
    HTH
    - Josh

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
  •