Jump to content

My parts are growing out of control?


Guest huey4657

Recommended Posts

Guest huey4657
Hi all,
Can someone please point out where i am going wrong?
[code]
while($SqlRow_GetStats = mysql_fetch_array($SqlRes_GetStats)) // if there is a row do this (300000+ times max)
{
extract($SqlRow_GetStats); // extract row into variables named after field name
$RaceIDs[$cnt] = $Race_ID;  // create array of IDs
$FPoss[$cnt] = $RaceEntry_FPos;  // create array of race finish position
$SPPoss[$cnt] = $RaceEntry_SPPos;  // create array of starting price position

for($num = 1; $num <= $SqlNum_GetSPos; $num++) // 18 times
{
$Row18[$num] = $num; // does the same as group by and sort
if($RaceEntry_FPos == "1")  // field extracted equals 1
{
$Win[$num]++; // increment array position by 1
}
elseif ($RaceEntry_FPos >= "2" AND $RaceEntry_FPos <= "3")  // field extracted is either 2 or 3
{
$Place[$num]++;  // increment array position by 1
}
else
{
$Lost[$num]++;  // increment array position by 1
}  // end if
}  // end for
[/code]

after printing contents of arrays they equal

$Win[1] = 36137 $Place[1] = 71719 $Lost[1] = 241535
$Win[2] = 36137 $Place[2] = 71719 $Lost[2] = 241535
$Win[3] = 36137 $Place[3] = 71719 $Lost[3] = 241535
etc...

thanks for your help



Link to comment
Share on other sites

Guest huey4657
Yes, sorry all
the problem was me, i had been coding all day and missed a conditional statement.

This worked...

while($SqlRow_GetStats = mysql_fetch_array($SqlRes_GetStats)) // if there is a row do this (300000+ times max)
{
extract($SqlRow_GetStats); // extract row into variables named after field name
$RaceIDs[$cnt] = $Race_ID;  // create array of IDs
$FPoss[$cnt] = $RaceEntry_FPos;  // create array of race finish position
$SPPoss[$cnt] = $RaceEntry_SPPos;  // create array of starting price position

for($num = 1; $num <= $SqlNum_GetSPos; $num++) // 18 times
{
$Row18[$num] = $num; // does the same as group by and sort
[color=red]if($RaceEntry_SPPos == $num) // if starting price position equals the loop number
{[/color]
if($RaceEntry_FPos == "1")  // field extracted equals 1
{
$Win[$num]++; // increment array position by 1
}
elseif ($RaceEntry_FPos >= "2" AND $RaceEntry_FPos <= "3")  // field extracted is either 2 or 3
{
$Place[$num]++;  // increment array position by 1
}
else
{
$Lost[$num]++;  // increment array position by 1
}  // end if
[color=red]} // end if[/color]
}  // end for


now i get the correct results below:

$Row18 = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 // saves me doing a group by and sort function

$Win[1] = 13713 $Place[1] = 12632 $Lost[1] = 13254 // outputs all race entries that are in starting position 1 and and have either won, placed or lost.
$Win[2] = 8057 $Place[2] = 14876 $Lost[2] = 17930 // same as above but for starting position 2
$Win[3] = 5289 $Place[3] = 13537 $Lost[3] = 22728 // starting position 3
etc... till 18.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.