I'm missing something

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a discrepancy in the number of elements in my arrays and can't see 
why.

Here is some code:
Note the lines with the ***

*** $plyrs = 0;
 unset($plyrnames_ar);
 unset($js_names);
 unset($js_seeds);
*** $rows = mysql_num_rows($qrslts);
***echo "in mysql there are $rows rows<br>";
 while ($row = mysql_fetch_array($qrslts))
 {   // build the name value here
  $mi = ($row['MI']=='') ? '' : " ".$row['MI'];
  $nm = $row['LastName'].", ".$row['FirstName'].$mi;
  if ($row['srtdbls']=='X')
  {
   $mi = ($row['partMI']=='') ? '' : " ".$row['partMI'];
   $nm .= "/".$row['partLN'].", ".$row['partFN'].$mi;
  }
***  $plyrs++;
  $plyrnames_ar[$nm] = $row['Draw_pos'];
 }
*** echo "before sort there are ".count($plyrnames_ar)." in 
plyrsnames_ar<br>";
 ksort($plyrnames_ar);
 foreach ($plyrnames_ar as $nm=>$sd)
 {
  $js_names[] = $nm;
  $js_seeds[] = $sd;
 }
*** echo "plyrs is $plyrs and there are ".count($js_names)." entries in 
js_rnames and ".count
***($plyrnames_ar)." entries in plyrnames_ar and ".count($js_seeds)." in 
js_seeds";
 exit();

The problem is that my $plyrs field comes up 18, while in truth there are 
only 17 rows of data in my database.
All of the other array-size counts echo out as being only 17, but my $rows 
and $plyrs fields come up as 18.  I was having problems with my javascript 
showing an undefined array element and took a bit o time to determine what 
it was and where it was happening.

Questions - does mysql_num_rows return a extra row that somehow doesn't get 
processed in the while loop? And if it does how come the counter ($plyrs) 
that I put into the loop comes up higher than it should.? 



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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux