tags:

views:

13

answers:

1

Has anyone used the Joomla banner Ads know how to make the Ads Rand() and DISTINCT. Everything I've tried to change on the banner.php page is not working. Here is what the code looks like. The images will Rand() just fine but they show up in duplicates.

$query = "SELECT *"
. ($randomise ? ', RAND() AS ordering' : '')
. ' FROM #__banner'
. ' WHERE ' . implode( ' AND ', $wheres )
. ' ORDER BY sticky DESC, ordering ';
A: 

Are you setting $randomise, otherwise 'ordering' won't be set. Also, you are specifying two order clauses, so both will be taken into account. I'm not sure what sticky menas, but you could just go: ORDER BY RAND()

$query = "SELECT * FROM #__banner WHERE " . implode( ' AND ', $wheres ) . " ORDER BY RAND()";
Ashley
Thanks for your reply, this is the banner code that came with the Joomla installation so I'm really not sure why they have two order clauses, found that strange myself. I actually had tried what you suggested with no luck, it still shows up with duplicates.
coder
I think there must be something else wrong with your code as that mysql will only select everything once. You could try remove the WHERE statement but I doubt it will make much difference
Ashley