question fuction manipulation

Ask about a PHP problem here.
Post Reply
User avatar
GenSwat
Posts: 74
Joined: Sat May 07, 2011 3:37 pm

question fuction manipulation

Post 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?
One of my Favorites
Image
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: question fuction manipulation

Post 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.
Image
User avatar
GenSwat
Posts: 74
Joined: Sat May 07, 2011 3:37 pm

Re: question fuction manipulation

Post 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
One of my Favorites
Image
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: question fuction manipulation

Post by jacek »

shuffle($players); 
This line randomises the array, for a specific order you will have to remove this.
Image
Post Reply