Forum Moderators: coopster

Message Too Old, No Replies

rand() issue

Doubling issue

         

hirerobhere

6:53 pm on Jul 21, 2008 (gmt 0)

10+ Year Member



I have an issue where I call two includes that are identical for featured ads on a real estate script and the ads are doubling up. Both files use the order by rand() function and are pulling the data from the same place. How can I prevent the same ads from show every now and then on both sides? Any ideas? Like is there a order by rand ascending and descending somehow? Thanks so much in advance.

WesleyC

7:45 pm on Jul 21, 2008 (gmt 0)

10+ Year Member



If you can get data from one function into the other...

Get the value of the primary key field from the first function call and store it. Then, when the second function is called, do the same SELECT statement, but add "WHERE my_primary_key != $other_ad_key".

eelixduppy

7:52 pm on Jul 21, 2008 (gmt 0)



Where are you grabbing the data from? IS it a database? You should be able to contruct a query that selects random ads to display.