As a beginner myself, I took this as an interesting challenge in working
with PERL syntax.

However, it seems there is a lot missing here. No DB connection, no array
names, $countresult looks undefined, and a couple of other things.

Is this the actual code? Does it actually work in PHP? I admit, I have been
doing PERL and PHP only since May, but it took a lot of massaging to get the
script you sent to work even in PHP.

Perhaps you could provied more info or more of the script?

-----Original Message-----
From: CDitty [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 31, 2001 9:14 PM
To: [EMAIL PROTECTED]
Subject: Converting PHP to Perl


In my attempt to learn perl and make it do what I want. I am attempting to 
convert some php code a friend of mine did a while back.   Unfortunately, 
with my knowledge of perl and php, this is a little over my head.  If 
anyone could look at the following code and tell me how to make it work in 
perl, I would appreciate it.  Unfortunately, my friend is not available, so 
I can't bug him.

Thanks

Chris

ps....Thanks for the help earlier Casey.  That did it.


$sql = mysql_query("Select id, trueodds, oneinodds, prize, picture from 
scratch_odds where trueodds = '0' and howmany > '0'") or die(mysql_error());
$count = MYSQL_NUMROWS($sql);  # just gives the number of rows returned.
$result = mysql_fetch_array($sql);   # assigns the sql result into an array

do{
         $tmp = rand($countresult[0], $countresult[1]); // Gives us random 
numbers between low and high in odds table.
}while($tmp == $result[0]);
         $rand[] = $tmp;

for($count = 1; $count < 3; $count++ ) // loops 3 times.
{
do{
         $tmp = rand($countresult[0], $countresult[1]);
}while(in_array($tmp, $rand) || ($tmp == $result[0]));
         $rand[] = $tmp;
}
$rand[] = $result[0];  # array 1
$rand[] = $result[0];  # array 2
$rand[] = $result[0];  # array 3


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to