eNdl
BANNED
- Jul 7, 2007
- 305
- 118
Hi,
I have a related articles script that just randomizes the results and instead of randomizing, I need the script to become static. I noticed the math function "rand" inside the code but I do I get change the code in order for the results to always stay the same. The code is below:
I have a related articles script that just randomizes the results and instead of randomizing, I need the script to become static. I noticed the math function "rand" inside the code but I do I get change the code in order for the results to always stay the same. The code is below:
PHP:
$q = $this->db->Query($sqlQuery);
while ($result = $this->db->Fetch($q)) {
$results[]=$result;
}
$resultsCount = count($results);
if($resultsCount>15){$resultsCount = 29;}
for ($z = 0; $z<=$resultsCount; $z++) {
$key = rand(0, count($results));
while(checkArr($keys, $key)) {
$key = rand(0, count($results));
}
$search = array(' ','?','%','#',':','!','.','@','$','^','&','*','(',')',';','=','[',']','{','}','/',',','"',"'",''');
$replace = array('-','','','','','','','','','','','','','','','','','','','','','','','','');
$keys[]=$key;
$link = str_replace($search, $replace, $results[$key]['Title']);
$resultArray[]['id']=$results[$key]['id']=$results[$key]['ArticleID'];
$resultArray[count($resultArray)-1]['link']=$link;
$resultArray[count($resultArray)-1]['title']=$results[$key]['Title'];
}
return $resultArray;
}