You are here: Re: MySql count « PHP Programming Language « IT news, forums, messages
Re: MySql count

Posted by Pedro Graca on 11/20/06 19:17

Andy Hassall wrote:
> On Mon, 20 Nov 2006 18:48:39 +0100, Michael Fesser <netizen@gmx.de> wrote:
>>.oO(Christoph Burschka)
>>>Akhenaten wrote:
>>>> The following snippet (for whatever reason) returns no value for the
>>>> count. Suggestions?
>>>> [...]

code re-inserted

>>>> $arr = array ("A", "B", "C", "D", "E");
>>>> foreach ($arr as $client) {
>>>> $count = mysql_query('SELECT COUNT(*) from table where columnA =
>>>> $client');
>>>> echo "$client has $count";
>>>> echo '<br>';
>>>> }

>>> 1. You can't pass variables within single quotes.
>>>
>>> 2. Strings in MySQL queries need to be surrounded by quotes
>>
>> 3. mysql_query() just returns a resource ID.
>
> 4. Always check for errors,

5. Indent your code. Always. Even for a very small example posted to
usenet.

--
I (almost) never check the dodgeit address.
If you *really* need to mail me, use the address in the Reply-To
header with a message in *plain* *text* *without* *attachments*.

 

Navigation:

[Reply to this 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

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