RE: [PHP] Any clever ideas on how to find some random records?

2005-04-26 Thread David Tucker
[OP]
I have a MySQL database with about a million records. I'd like to use the
SQL command "order by RAND()" but my ISP won't let me: whenever the server
gets spidered, Google overloads their MySQL server because of all the
overhead of that command. I can't just cloak the spiders because I need them
to find the random pages.

So...what I've been doing for small sets of records is to use PHP to
generate a bunch of random record ID's, then I construct a long SQL
statement to find all the matching records. This works, but if I want to
generate a big index page to list a hundred or a thousand records, it could
get pretty clunky.

Anyone have any better suggestions?   :)
[/OP]

Well, not knowing what the random records are used for and not really
knowing how random they need to be ;) I might suggest just selecting a
random number and then select all the records after it until you have the
amount you need.  Probably not the best solution, but might work for you.

--Codefox

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



RE: [PHP] how to read a specific "cell"

2005-04-26 Thread David Tucker
I would do it like this :

if (mysql_data_seek($result, $rownum))
$a_row = mysql_fetch_row($result);

echo $a_row[$column_int];

--Codefox

-Original Message-
From: Sebastien Pahud [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 26, 2005 5:52 PM
To: php-general@lists.php.net
Subject: Re: [PHP] how to read a specific "cell"

Brian V Bonini wrote:

>On Tue, 2005-04-26 at 17:05, Sebastien Pahud wrote:
>  
>
>>Hello,
>>
>>I cannot figure out how to read a specific "cell" in a result i got 
>>from a SQL request.
>>
>>I have a SQL request on a database:
>>SELECT nameAttribute, fr, de, en
>>FROM traduction
>>WHERE nameTable = 'whatever'
>>AND idTable = 1
>>ORDER BY nameAttribute
>>
>>and i am suppose to get something like this :
>>
>>-
>>| msg   | bonjour  | gutentag | good morning |
>>-
>>| time   | diner  | essen  | lunch |
>>-
>>| weather | beau  | schön | nice|
>>-
>>
>>I always know how many rows i am suppose to get.
>>
>>Now, how can i get the word "schön" for example out from that table
>>
>>
>
>SELECT * FROM traduction WHERE nameAttribute='weather' AND de='schön';
>
>??
>  
>
Thanks Brian, but you didn't get the problem... i want to get the content
with the "position" in the array, because i never know what is inside my
array. ("schön" and all those inputs change) But i know the position of what
i need. (because of the ORDER BY and the fact that i always get only 3 rows)

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

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