Note Submitter: euan_m at yahoo dot fr
----
You could try this, it works fine :
<?php
$connection = mysql_connect ($host, $login, $password);
mysql_select_db ($DataBase, $connection) ;
$c = 5 ; // Whatever..
protected function randomselection($c, $connection) {
$data = getdata($connection) ; // Get your datas somewhere you like to
$totalcount = count($data) ;
$j = array() ;
if ($c > $totalcount) { $newdata = $data ; } // if not enough datas rows in $data
else {
for($i = 0; $i <= $c; $i++) {
$exists = 1 ;
for($exists > 0; $exists++;) {
$test = mt_rand(1,$totalcount) ; // depends on where you want to start - can also use rand()
if(!in_array( $test , $j )) { $j[$i] = $test ; $exists = 0 ; }
}
$newdata[$i] = $data[$j[$i]] ;
}
}
return $newdata ;
}
?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.