Meth0d
Thu 7 June 2007, 10:10 am GMT +0200
i have tried a few different methods, but seem to run into a few problems with each.. what im basically trying to do is load a random ID from an array of banner_id's . this random ID (whatever it may be based on the solution found from your help in this thread) will be used in a function to display the banner based on DB data of course 8)
here is what i have for putting the banner_id's into an array, for some reason when i print_r on this array it shows some really strange results, as if there are like 6-8 banner ID's where there are really only 4 in the DB currently.
$bannerQ = dbquery("SELECT * FROM ".$db_prefix."banners WHERE banner_state = '1'");
while ($bannerData = dbarray($bannerQ))
$bannerID[] = $bannerData['banner_id'];
?>
Then, we have to shuffle or randomize them somehow.. what i have here sort of works, but sometimes displays no banner or never the other 2 banners (only shows the first two)
$banners = array_rand($bannerID);
?>
I have also tried to use shuffle() on the bannerID, but im not doing it right or something because it returns empty result :( So how do I further randomize the $bannerID array, and then get that ID correctly? Thanks in advance for hte help
here is what i have for putting the banner_id's into an array, for some reason when i print_r on this array it shows some really strange results, as if there are like 6-8 banner ID's where there are really only 4 in the DB currently.
$bannerQ = dbquery("SELECT * FROM ".$db_prefix."banners WHERE banner_state = '1'");
while ($bannerData = dbarray($bannerQ))
$bannerID[] = $bannerData['banner_id'];
?>
Then, we have to shuffle or randomize them somehow.. what i have here sort of works, but sometimes displays no banner or never the other 2 banners (only shows the first two)
$banners = array_rand($bannerID);
?>
I have also tried to use shuffle() on the bannerID, but im not doing it right or something because it returns empty result :( So how do I further randomize the $bannerID array, and then get that ID correctly? Thanks in advance for hte help