[PHP] ORDER BY RAND()....

2003-10-29 Thread Payne
Hi,

I have been working on a simple PHP script that called to a mysql 
database, where I  do the following

SELECT url FROM sponsors ORDER BY RAND();

When I do a refresh I keep getting the same url, I have test this sql 
statement in mysql and it works great. I think my problem is this...

Here is my php script

?

   $db = mysql_connect(69.15.40.130,cepayne,death);

   mysql_select_db(links,$db);

   $result = mysql_query(SELECT url FROM sponsors order by 
rand() LIMIT 1, $db);

  if ($myrow = mysql_fetch_array($result)) {

   echotable width='500' border='0' cellspacing='0' 
cellpadding='0';
  
  do {
 
  printf(trtd%s/td/tr\n,$myrow[url]);
  
  } while ($myrow = mysql_fetch_array($result));
  
  } else {
  
  echo Sorry, no message of day today;
  }

 echo /table

?

I  know that what I have got here must be the problem because this  code 
was use to get mutli line of results. Is there a way to retype this so 
that I only get the one statement I need?

Payne

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


Re: [PHP] ORDER BY RAND()....

2003-10-29 Thread Gerard Samuel
On Wednesday 29 October 2003 02:24 pm, Payne wrote:
 Hi,

 I have been working on a simple PHP script that called to a mysql
 database, where I  do the following

 SELECT url FROM sponsors ORDER BY RAND();

Try -
SELECT url FROM sponsors ORDER BY RAND() LIMIT 1;

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



Re: [PHP] ORDER BY RAND()....

2003-10-29 Thread Payne
Gerard Samuel wrote:

On Wednesday 29 October 2003 02:24 pm, Payne wrote:
 

Hi,

I have been working on a simple PHP script that called to a mysql
database, where I  do the following
SELECT url FROM sponsors ORDER BY RAND();
   

Try -
SELECT url FROM sponsors ORDER BY RAND() LIMIT 1;
 

I did that same thing.

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


RE: [PHP] ORDER BY RAND()....

2003-10-29 Thread Chris W. Parker
Payne mailto:[EMAIL PROTECTED]
on Wednesday, October 29, 2003 11:54 AM said:

 Try -
 SELECT url FROM sponsors ORDER BY RAND() LIMIT 1;
 
 
 
 I did that same thing.

SELECT url FROM sponsors ORDER BY column RAND() LIMIT 1;

How about that one?



Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

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



Re: [PHP] ORDER BY RAND()....

2003-10-29 Thread Payne
Ok, this gives me an error. I guess what I was asking early is there 
away to print an echo without doing myrow? Why can I do echo $result 
without getting Resource id # My thinking is if you look at my first 
e-mail, my code is trying to fetch multi-rows from the database, I don't 
need multi row,  I thinking becaue fetch calls the database multi time 
that it defects the rand() function.

Payne

Chris W. Parker wrote:

Payne mailto:[EMAIL PROTECTED]
   on Wednesday, October 29, 2003 11:54 AM said:
 

Try -
SELECT url FROM sponsors ORDER BY RAND() LIMIT 1;


 

I did that same thing.
   

SELECT url FROM sponsors ORDER BY column RAND() LIMIT 1;

How about that one?



Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/
 

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