RE: [PHP] Easy array stuff I think for those who can I guess.
| From: | John W. Holmes | Date: | Fri, 06 Dec 2002 01:33:32 +0000 |
| Subject: | RE: [PHP] Easy array stuff I think for those who can I guess. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-127214@lists.php.net to get a copy of this message | ||
If this is mysql, you can use
SELECT * FROM konkuranse ORDER BY RAND() LIMIT 1
To get a random row and skip all that stuff you have...
---John Holmes...
> -----Original Message-----
> From: Raymond Lilleodegard [mailto:raymol@online.no]
> Sent: Thursday, December 05, 2002 5:36 PM
> To: php-general@lists.php.net
> Subject: [PHP] Easy array stuff I think for those who can I guess.
>
> Hi!
>
> I am trying to get out a value of an array that I have made from a
query
> and
> deliver the value into a variable. I have made this code. Am I totally
> lost?
>
>
> while ($myrow = mysql_fetch_array($result));
> {
>
> $id = $myrow['id'];
>
> $deltaker[] = array ($id);
>
> }
>
> $limit = count($deltaker);
>
>
> $finn_vinner = rand(0,$limit);
>
> $vinner_deltaker = $deltaker[$finn_vinner];
>
> $vinner_id = current($vinner_deltaker);
>
>
> $sql2 = "SELECT * FROM konkuranse WHERE id = '$vinner_id'";
>
>
> Best regards Raymond
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php