Guest huey4657 Posted August 11, 2006 Share Posted August 11, 2006 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 positionfor($num = 1; $num <= $SqlNum_GetSPos; $num++) // 18 times{$Row18[$num] = $num; // does the same as group by and sortif($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] = 241535etc...thanks for your help Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted August 11, 2006 Share Posted August 11, 2006 What are you trying to accomplish? Unless you tell us what the desired output is, we can't help. Quote Link to comment Share on other sites More sharing options...
king arthur Posted August 12, 2006 Share Posted August 12, 2006 Doesn't look like there's anything actually wrong with that code. Your FOR loop will do exactly the same each tiime as the IF statement tests the same variable each time, so of course you will get all the rows the same. Quote Link to comment Share on other sites More sharing options...
Guest huey4657 Posted August 12, 2006 Share Posted August 12, 2006 Yes, sorry allthe 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 positionfor($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 fornow 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 3etc... till 18. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.