[PHP] Easy array stuff I think for those who can I guess.

2002-12-05 Thread Raymond Lilleodegard
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




RE: [PHP] Easy array stuff I think for those who can I guess.

2002-12-05 Thread John W. Holmes
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:[EMAIL PROTECTED]]
 Sent: Thursday, December 05, 2002 5:36 PM
 To: [EMAIL PROTECTED]
 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




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