"Chris" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> ////////$sql = "SELECT * FROM agentdb WHERE ((OfficeID <> 214) and
> (agentdb.agent_id<> 1115421) and (agentdb.agent_id > 100) and
> agentdb.agent_id <> 333)) ORDER BY RAND() LIMIT 1";
>
> The above code should generate a random agent upon refresh.
>
> It does however seem to favor one agent more than the others. The agent id
>
> it used to favor was "333" i added the "(agentdb.agent_id <> 333)" to
>
> disallow that agent from being displayed. But now it wants to favor an
agent
>
> whose id number is "1167553"
>
> The function can be seen here: http://c21alliancerealty.com/area.php it is
>
> the random "Featured Agent" on the left hand side of the page.
>
> Does anyone have any suggestions as to why this is occuring, please?

I don't have any suggestions as to why this happens.  Very strange.  One
thing you could do instead is depend on PHP's random numbers.

srand ((double) microtime() * 1000000);
$r = mysql_query('select count(*) as cnt from agentb');
$cnt = mysql_result($r, 0, 0);
mysql_free_result($r);
$rnd = rand(1, $cnt);
$sql = "SELECT * FROM agentdb WHERE ((OfficeID <> 214) and
(agentdb.agent_id<> 1115421) and (agentdb.agent_id > 100) and
agentdb.agent_id <> 333)) LIMIT $rnd, 1";

A bit more work than just relying on MySQL, but maybe it will actually be
random...

  -- Rob

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to