Ask a Question related to PHP Programming, Design and Development.
-
Binay Agarwal #1
Re: [PHP] Random selection
Hi
You can use "select distinct names from table_name order by rand() limit 3".
Hope this helps and let me know.
cheers
Binay
----- Original Message -----
From: <fkeessen@planet.nl>
To: <php-general@lists.php.net>
Sent: Saturday, August 23, 2003 6:36 PM
Subject: [PHP] Random selection
may not produce two times the same name. For example;> Hi,
>
> Can you help me with this one??
>
> In my mysql db i have a colum called names;
>
> In names their are:
>
> Frank
> Frank
> Bob
> Alice
> Bob
> Alice
> Jim
> Alice
> Frank
>
> I want to make a random selection (max 3 value's for example).. Only it>
> This is the output:
>
> Frank, Jim, alice
>
> Wrong output
>
> Frank, Frank, Jim
>
> Please help!
>
> Thanks,
>
> Frank
>
>
>
----------------------------------------------------------------------------
----
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
Binay Agarwal Guest
-
Using Math.random to go to random frames
Hello everyone. My cerebral density is preventing me from seeing the solution to this problem. I have the following code which causes the user to... -
Random frame selection?
I have just started using Director, so this is probably a simple/stupid question. Anyway, I am doing a short story in which the user can interact... -
Random Button Selection
I am creating a CDROM presentation using Director MX (Mac/PC delivery). This presentation has a couple of sections that have a number of buttons that... -
Disconected Recordset & Random Selection
Hello All, How would I go about using a disconnect recordset and select (x) records from it, x being the number of records to be selected. ... -
Random image in a random place.
Anyone know javascript? I have a grid(4 x 4) of 16 spacer images and a few text links on the side. Each text link represents a different folder of... -
fkeessen@planet.nl #2
Random selection
Hi,
Can you help me with this one??
In my mysql db i have a colum called names;
In names their are:
Frank
Frank
Bob
Alice
Bob
Alice
Jim
Alice
Frank
I want to make a random selection (max 3 value's for example).. Only it may not produce two times the same name. For example;
This is the output:
Frank, Jim, alice
Wrong output
Frank, Frank, Jim
Please help!
Thanks,
Frank
fkeessen@planet.nl Guest
-
Jim Lucas #3
Re: [PHP] Random selection
Try this:
SELECT name FROM table GROUP BY name ORDER BY RAND() LIMIT 3
This will group together all the names and then choose from a list that has
only unique names and then return 3 at random.
Jim Lucas
----- Original Message -----
From: <fkeessen@planet.nl>
To: <php-general@lists.php.net>
Sent: Saturday, August 23, 2003 6:06 AM
Subject: [PHP] Random selection
may not produce two times the same name. For example;> Hi,
>
> Can you help me with this one??
>
> In my mysql db i have a colum called names;
>
> In names their are:
>
> Frank
> Frank
> Bob
> Alice
> Bob
> Alice
> Jim
> Alice
> Frank
>
> I want to make a random selection (max 3 value's for example).. Only it>
> This is the output:
>
> Frank, Jim, alice
>
> Wrong output
>
> Frank, Frank, Jim
>
> Please help!
>
> Thanks,
>
> Frank
>
>
>
----------------------------------------------------------------------------
----
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.phpJim Lucas Guest
-
pwiop #4
Random selection
I have a number of details stored in an xml document that I use to dynamically
create content on a webpage. I have sorted it so only four items are displayed.
All fine and dany so far and working a treat.
What I want to know is, is it possible to randomly select four items from the
xml files each time the page is accessed or refreshed
If it is any help the code I am using at present in the xsl file is here;
<xsl
aram name="itemsPerPage" select="5" />
<xsl:template match="/">
<h1><xsl:value-of select="rss/channel/title"/></h1>
<div id="intro"><xsl:value-of select="rss/channel/description"
disable-output-escaping="yes"/></div><br /><!--<p>-->
<xsl:for-each select="rss/channel/item[position() <= $itemsPerPage]">
<h2><xsl:value-of select="title"/></h2>
<div id="dateShow">Date posted - <xsl:value-of select="pubDate"/></div>
<p><xsl:value-of select="description" disable-output-escaping="yes"/><br
/><a href="{link}">more . . .</a></p><br />
</xsl:for-each>
<p><a href="#">More NEWS :: EVENTS :: UPDATES</a></p>
<!--</p>-->
</xsl:template>
pwiop Guest



Reply With Quote

