Przypomniałem sobie, że mam jednak tutaj użytkownika.
Cytat(gino @ 31.05.2011, 17:50:12 )

Co przyjmuje zmienna $this->numberofr ?
Podstawiłem do tej funkcji liczby 10 cyfrowe i działa ok, wykonanie poniżej sekundy. Jak duże liczby przyjmuje ta zmienna ?
Przyjmuje liczbę wierszy pobraną z bazy mysql. Bardzo duża na pewno nie jest, pewnie trochę ponad 100.
Pozdrawiam.
P.s. Może dodam cały kod pliku (moduł ma za zadnie pobieranie danych z bazy mysql, które zapisał tam komponent DJ Catalog 2)
<?php defined('_JEXEC') or
die('Restricted access'); class get_records
{
var $numberofr, $result;
function get_records()
{
$query="SELECT * FROM jos_djc2_items";
$this->numberofr = mysql_numrows($this->result); //number of rows $this->numberofr--;
}
function get_datas()
{
$randomnumber = $this->losuj();
for($i = 0 ; $i < 3 ; $i++)
{
$data[$i]["image"] = mysql_result($this->result, $randomnumber[$i], "image_url"); $data[$i]["name"] = mysql_result($this->result, $randomnumber[$i], "name"); $cat_id = mysql_result($this->result, $randomnumber[$i], "cat_id"); $id = $randomnumber[$i] + 3;
//$cat_id++;
$data[$i]["link"] = 'index.php?option=com_djcatalog2&view=item&id='.$id.'&cid='.$cat_id.'&Itemid=568';
$cat_id = $cat_id - 3;
$query = "SELECT * FROM jos_djc2_categories";
$data[$i]["cat_name"] = mysql_result($result2, $cat_id, "name"); }
return $data;
}
function losuj()
{
$randnum[0
] = mt_rand(0
, $this->numberofr);
do{
$randnum[1
] = mt_rand(0
, $this->numberofr); }while($randnum[0] == $randnum[1]);
do{
$randnum[2
] = mt_rand(0
, $this->numberofr); }while($randnum[2] == $randnum[1] || $randnum[0] == $randnum[2]);
return $randnum;
}
}
?>
EDIT.
Już wszystko działa, przynajmniej u mnie. Nie wiem jednak dlaczego, ale osoba, której robię ten skrypt mówi, że na Firefoxie dalej mu nie działa (mimo, że u mnie wszystko jest ok na każdej przeglądarce).
Co może być tego przyczyną ?
Ma ktoś jakiś pomysł ?