RE: [PHP-DB] Random Selecting from mySQL

From: Date: Thu, 14 Mar 2002 00:32:20 +0000
Subject: RE: [PHP-DB] Random Selecting from mySQL
References: 1  Groups: php.db php.general 
Request: Send a blank email to php-db+get-17669@lists.php.net to get a copy of this message
Hi! Do you have a primary key field in the table? If yes, you can after displaying the first 10 records you can put the primary key values of those records in an array and have "primary_key_fiels NOT IN (array_values_seperated_by_commas)" in your quesry.. So when you display your first page with 10 records, then you won't have any restricting values because the array will be empty. When you display it second time then you will have the first 10 records excluded and your array will be populated 20 values so that when you display the third page thos 20 will be excluded and vice versa.. Did I confuse you enough?:) I hope this helps.. Gurhan -----Original Message----- From: Georgie Casey [mailto:webmaster@filmfind.tv] Sent: Wednesday, March 13, 2002 7:11 PM To: php-general@lists.php.net; php-db@lists.php.net Subject: Re: [PHP-DB] Random Selecting from mySQL yea, i know how to display 10 results per page, but that doesnt work when you want to do a ORDER BY rand() query. "Gurhan Ozen" <c-gurhan.ozen@wcom.com> wrote in message news:NEBBJFKICMBBMAOHJDFOCEHNDAAA.c-gurhan.ozen@wcom.com... > are you just looking for a way to display 10 results per page? If yes then > you can just use LIMIT to limit your result to 10 .. So, for the first page, > you can do "SELECT .... LIMIT 1, 10;" and for the second page "SELECT ... > LIMIT 11, 20" etc etc . > You can sure use "ORDER BY" with "LIMIT" to to sort the results for a > given criteria .. > > Gurhan > > > -----Original Message----- > From: Georgie Casey [mailto:webmaster@filmfind.tv] > Sent: Wednesday, March 13, 2002 2:00 PM > To: php-db@lists.php.net; php-general@lists.php.net > Subject: [PHP-DB] Random Selecting from mySQL > > > I know how to use the "ORDER BY rand()" command on the end of queries to > randomize selection, but that's no good when you want to only display 10 > results per page. The next page the user chooses, randomizes again and could > show duplicate fields and not at all show other fields. > > Does anyone know a way round this? > > -- > Regards, > Georgie Casey > webmaster@filmfind.tv > > *************************** > http://www.filmfind.tv > Ireland's Online Film Production Directory > *************************** > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.db (#17669) next »