Re: random?
| From: | Rob Adams | Date: | Fri, 30 Jan 2004 22:20:15 +0000 |
| Subject: | Re: random? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-176264@lists.php.net to get a copy of this message | ||
Chris,
I've checked your site and see you're still having the problem. What
exactly isn't working?
-- Rob
"Chris" <chris@glyndower.com> wrote in message
news:NGBBJMAGGLDFGFIBEIJFOEAHHIAA.chris@glyndower.com...
> Hi Rob,
>
> Thanks for the idea....I think it is probably a better way to go also.
> Hers what I came up iwth...and the rest of the code pertaining to the
goal.
>
> I'm sure that I'm, overlooking something simple here, but I can't seem to
> make this work...
>
>
> srand ((double) microtime() * 1000000);
> $r = mysql_query('select count(*) as cnt from agentdb');
> $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";
> $results= mysql_query($sql);
> $agent=mysql_fetch_array($results);
> $agent_ref = $agent['agent_ref'];
> $agent_id = $agent['agent_id'];
> $agent_first = $agent['agent_first'];
> $agent_last = $agent['agent_last'];
> $agent_first = rawurldecode($agent_first);
> $agent_last = rawurldecode($agent_last);