Page 1 of 1

question fuction manipulation

Posted: Tue May 17, 2011 12:01 pm
by GenSwat
<?php
  

include ( 'dbconnect.php' );
       
        
$query  = "SELECT `id` , `name` FROM `users`";
$result = mysql_query ( $query ) or die ("<p class=err>Error - Query failed: ".mysql_error()."</p>");

        while($row = mysql_fetch_array( $result ) ) {
              $players[$row['id']] = $row;              
        }
       
srand(214134);
mt_srand(214134);
shuffle($players);      

?>

I have srand and mt _random controling the shuffle of players.If I change these values to match as they are, with new values that match.My Players will randomly change on my tournament bracket. this is a mthod to keep players that signup finding out a patern of who they would play.


Question could I make this so I could control those number through the webpage, So on the admin page the admin could select the numbers he wanted to gernerate the order list?

Re: question fuction manipulation

Posted: Tue May 17, 2011 2:04 pm
by jacek
The mt_rand function is doing nothing here :?

For the admin to choose the order you would have to add an extra column to the table called "order" or something similar. This would be set by the admin, and you could use ORDER BY to use it as the order of the rows.

Re: question fuction manipulation

Posted: Tue May 17, 2011 7:46 pm
by GenSwat
yes it stop the page from change on refresh when I had one or other it keep changing on refresh when I added them both it stops
so if I change them to a differant number and make them match each other it will rotate the database order

Re: question fuction manipulation

Posted: Tue May 17, 2011 8:05 pm
by jacek
shuffle($players); 
This line randomises the array, for a specific order you will have to remove this.