Reply to Re: Count problem

Your name:

Reply:


Posted by Andy Hassall on 06/20/05 22:18

On 20 Jun 2005 11:39:15 -0700, "Bryan" <bryanilton@gmail.com> wrote:

>I've been trying to work out a problem but I'm having no luck. I have
>field in my table for area and I need to count the number of matches
>and assign a variable for each one.. this is what I have but it doesn't
>work.. any ideas?

*sigh* In what way does it not work?

What did you expect it to do?
What does it do?
How do the two differ?

Saying "it doesn't work" without explaining what it does do is not helpful and
could result in getting replies that are even more irritable than this one ;-)

>$testcount = mysql_query("select area, count(area) as newcount from rea
>group by area order by area");

You haven't checked whether this query worked or not.

Check the return value. If it is false, then the query has failed. The error
is available from mysql_error().

It will also show a warning message, unless you have PHP configured to not
show or log warnings.

You must develop code with errors enabled (see the display_errors and
error_reporting options), and preferably warnings set to maximum, else you are
coding blindfolded.

One thing that jumps out is whether the table really called 'rea'? Or did you
mean 'area'?

With error checking and errors displayed, PHP would have told you this, and
you'd be certain about what's wrong - instead you're posting to thousands of
people asking them to guess based on insufficient information.

>while ($returncount = mysql_fetch_array($testcount)) {
>if ($returncount[area] == 'RCC') {

Associative array keys should be quoted else it'll raise a warning. It
wouldn't stop the code working, though (unless you had a constant named
'area').

>$rccn = $returncount[newcount];
>}
>if ($returncount[area] == 'RCL') {
>$rccl = $returncount[newcount];
>}
>if ($returncount[area] == 'RCH') {
>$rcch = $returncount[newcount];
>}
>if ($returncount[area] == 'RCW') {
>$rccw = $returncount[newcount];
>}
>if ($returncount[area] == 'RNK') {
>$rnkn = $returncount[newcount];
>}
>if ($returncount[area] == 'RNK') {
>$rnen = $returncount[newcount];
>}
>}

OK, so how do you know it didn't work?

You need to post an example of the input data and the output data to prove it
didn't work.

--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация