RE: [PHP] Parsing recordsets - only first row returned

2004-03-18 Thread Chris W. Parker
Alex Hogan mailto:[EMAIL PROTECTED]
on Thursday, March 18, 2004 10:39 AM said:

 Hi All,
 
 
 
 I am parsing data returned from a field that looks like this;
 
 
 
 6-8-3-5-10-9-6__7-5-9--etc...
 
 
 
 The code below parses out the data they way I want it but only
 returns the first row.  I need to compare all rows and return an
 average from each of the parsed out numbers.  Where have I made a
 mistake? 
 
 
 

thanks for all the white space. one blank line isn't enough for my brain
to properly separate the different parts of your email. but now, thanks
to your extra white space i don't have a headache anymore. thanks again!
it really helps!

and now to more serious matters... ;)

 while($row = mssql_fetch_array($result)){

you're grabbing the entire result set all at once so you'll only execute
this while statement once. that's why it only does the first line. do
the the following instead:

$entire_recordset = mssql_fetch_array($result);

foreach($entire_recordset as $row)
{
// looping code goes here
}

this is just my take on your code at first glance.


hth,
chris.

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



Re: [PHP] Parsing recordsets - only first row returned

2004-03-18 Thread John W. Holmes
From: Alex Hogan [EMAIL PROTECTED]

 I am parsing data returned from a field that looks like this;

  6-8-3-5-10-9-6__7-5-9--etc...

Wow... you're totally missing the point of a database when you store data
like this.

 The code below parses out the data they way I want it but only returns the
 first row.  I need to compare all rows and return an average from each of
 the parsed out numbers.  Where have I made a mistake?



 $i = 0;

 $total = array();

 while($row = mssql_fetch_array($result)){

So how many times does the while() loop execute? How many rows is your query
actually returning? What does the output actually look like and what should
it look like.

---John Holmes...

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



RE: [PHP] Parsing recordsets - only first row returned

2004-03-18 Thread Alex Hogan
 thanks for all the white space. one blank line isn't enough for my brain
 to properly separate the different parts of your email. but now, thanks
 to your extra white space i don't have a headache anymore. thanks again!
 it really helps!

Anything I can do.., just a little present from MS Outlook.  Glad to hear
your headache is gone though.

 $entire_recordset = mssql_fetch_array($result);
 
 foreach($entire_recordset as $row)
 {
 // looping code goes here
 }

Thanks...


alex hogan


** 
The contents of this e-mail and any files transmitted with it are 
confidential and intended solely for the use of the individual or 
entity to whom it is addressed.  The views stated herein do not 
necessarily represent the view of the company.  If you are not the 
intended recipient of this e-mail you may not copy, forward, 
disclose, or otherwise use it or any part of it in any form 
whatsoever.  If you have received this e-mail in error please 
e-mail the sender. 
** 




RE: [PHP] Parsing recordsets - only first row returned

2004-03-18 Thread Alex Hogan
 Wow... you're totally missing the point of a database when you store data
 like this.

Not my db...  

 So how many times does the while() loop execute?

Once

How many rows is your query actually returning?

Just one.

What does the output actually look like and what should it look like.

9
8
9
...

It should produce an average.

7.36
8.01
...



alex


** 
The contents of this e-mail and any files transmitted with it are 
confidential and intended solely for the use of the individual or 
entity to whom it is addressed.  The views stated herein do not 
necessarily represent the view of the company.  If you are not the 
intended recipient of this e-mail you may not copy, forward, 
disclose, or otherwise use it or any part of it in any form 
whatsoever.  If you have received this e-mail in error please 
e-mail the sender. 
**