RE: [PHP] random order
| From: | John Holmes | Date: | Mon, 13 May 2002 06:37:17 +0000 |
| Subject: | RE: [PHP] random order | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-97296@lists.php.net to get a copy of this message | ||
I don't know if this will work or not, but try
SELECT * FROM table ORDER BY id, RAND();
That should keep all of the questions and answers together, but give a
random order for the answers.. ?? Like I said, not exactly sure on it
though.
Best option, like someone else said, is to split this up into two
tables.
---John Holmes...
> -----Original Message-----
> From: Jule [mailto:jslootbeek@clarku.edu]
> Sent: Sunday, May 12, 2002 1:28 PM
> To: holmes072000@charter.net; php-general@lists.php.net;
> mysql@lists.mysql.com
> Subject: Re: [PHP] random order
>
> hmm it got a little more complicated now,
> i have a table with: id title question answer1 answer2 answer3
answer4.
> how can i use all of those in a php page but only randomize the
answers?
>
> so i get
>
> title title
>
> question question
>
> answer3 answer4
> answer2 answer1
> answer4 answer3
> answer1 answer2
>
> any ideas?
> thanks,
>
> Jule
> On Sunday 12 May 2002 17:30, you wrote:
> > Add on a LIMIT to restrict it to return a certain number of rows.
> >
> > If you had a table of say, 100 rows, and you wanted four random ones
out
> > of the 100, then you'd use this:
> >
> > SELECT * FROM table ORDER BY RAND() LIMIT 4;
> >
> > ---John Holmes...
> >
> > > -----Original Message-----
> > > From: Jule [mailto:jslootbeek@clarku.edu]
> > > Sent: Sunday, May 12, 2002 11:22 AM
> > > To: holmes072000@charter.net
> > > Subject: Re: [PHP] random order
> > >
> > > Thanks John,
> > > I thought that that command only selected a random row..
> > > must've read wrong.
> > > thanks.
> > >
> > > Jule
> > >
> > > On Sunday 12 May 2002 17:21, you wrote:
> > > > Nothing to do with PHP...
> > > >
> > > > SELECT * FROM table ORDER BY RAND();
> > > >
> > > > ---John Holmes...
> > > >
> > > > > -----Original Message-----
> > > > > From: Jule [mailto:jslootbeek@clarku.edu]
> > > > > Sent: Sunday, May 12, 2002 9:49 AM
> > > > > To: php-general@lists.php.net
> > > > > Subject: [PHP] random order
> > > > >
> > > > > Hey guys and gals,
> > > > > I have a problem:
> > > > > I have a mysql databse with 4 rows, and each row (row1, row2,
> >
> > row3,
> >
> > > > and
> > > >
> > > > > row4)
> > > > > contains a sentence. now i want these sentences to appear in
> >
> > random
> >
> > > > order:
> > > > > instance: 1 2 etc.
> > > > > row2 row4
> > > > > row4 row2
> > > > > row1 row1
> > > > > row3 row3
> > > > >
> > > > > how do i go about that??
> > > > > any ideas apreciated.
> > > > > thanks
> > > > >
> > > > > Jule
> > > > > --
> > > > >
> > > > > |\/\__________________________/\/|
> > > > > | Jule Slootbeek |
> > > > > | jslootbeek@clarku.edu |
> > > > > | http://blindtheory.cjb.net |
> > > > > | __________________________ |
> > > > > |/\/ \/\|
> > > > >
> > > > > --
> > > > > PHP General Mailing List (http://www.php.net/)
> > > > > To unsubscribe, visit:
> > > > > http://www.php.net/unsub.php
> > >
> > > --
> > >
> > > |\/\__________________________/\/|
> > > | Jule Slootbeek |
> > > | jslootbeek@clarku.edu |
> > > | http://blindtheory.cjb.net |
> > > | __________________________ |
> > > |/\/ \/\|
>
> --
> |\/\__________________________/\/|
> | Jule Slootbeek |
> | jslootbeek@clarku.edu |
> | http://blindtheory.cjb.net |
> | __________________________ |
> |/\/ \/\|