1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Rep Power
    hello i want to shuffle an array with many
    fields in it, but it won't work, if i have an
    array with 1 field in it, it works.

    i retrieve information from a mysql table,
    but i want to put the information
    in a random sequence, so that not everytime
    the same information is on top.
    here's my code :

    how do i display the array at random ?$result = mysql_query("select * from inventory where groep='NIEUW' order by id1 DESC LIMIT 0, 50 ");

    if ($myrow = mysql_fetch_array($result)) {

    echo '<TABLE class="hoofd" cellspacing="2" cellpadding="0">';
    kopregel("new CD's ");

    //echo mysql_num_rows($result);

    do {
    if ($i/2 == floor($i/2)) {
    else {
    echo '</TR></TABLE></TD></TR>';

    } while ($myrow = mysql_fetch_array($result));

    echo "n";

    } else {

    echo "Sorry, no records were found!";

    i appreciate yours help

    Jan the netherlands

  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Niagara Falls (On the wrong side of the gorge)
    Rep Power
    I'm sorry, I'm not really following your code to well. It would help if you included the user functions you are using.

    However, I would make one suggestion. If you want the rows randomized do this immediately after the query:

    Now, you can randomize from 0 to numrows-1 and display that record. Then unset() that part of the array (assuming $random contains the random number generated)


    After each random number generation use isset() to check if that row is still there, if not generate a new random number.

    Not very efficient but it'll do what you want.

Similar Threads

  1. sort: find duplicate string elements in array
    By sciencelife in forum Java Help
    Replies: 3
    Last Post: January 27th, 2004, 01:29 PM
  2. C++ programming help.
    By Programming1 in forum C Programming
    Replies: 1
    Last Post: January 20th, 2004, 10:47 AM
  3. another remove array values from an array
    By robee in forum PHP Development
    Replies: 6
    Last Post: November 20th, 2003, 12:09 AM
  4. multi dimensional arrays - Can't grasp how to?
    By Kaleina in forum PHP Development
    Replies: 17
    Last Post: November 5th, 2003, 03:18 PM
  5. problem with array
    By Geekoidxp in forum PHP Development
    Replies: 3
    Last Post: October 12th, 2003, 01:22 PM

IMN logo majestic logo threadwatch logo seochat tools logo