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

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

*** $plyrs = 0;
*** $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 
 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 

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

Reply via email to