You are here: Re: displaying count « All PHP « IT news, forums, messages
Re: displaying count

Posted by lorento on 02/06/07 05:04

I think there is a better method :
<?php
$sqlcount = "SELECT COUNT(name) AS c FROM mainpage where lingo =
'en'";
$result = mysql_query ($sqlcount);

while ($row = mysql_fetch_object($result))
$resultcount = $row->c;

echo $resultcount;
?>

http://www.mastervb.net/phpbooks/
http://www.mastervb.net

On Jan 5, 11:08 pm, Bill <n...@noreturn.f9.co.uk> wrote:
> Thanks rik thats what was wrong
>
> $sqlcount = "SELECT name, text FROM mainpage where lingo = 'en'";
> $resultRES = mysql_query ($sqlcount);
> $resultcount = mysql_num_rows($resultRES);
>
> echo $resultcount;
>
> the above worked fine
> cheers
>
> Rik wrote:
> > Bill wrote:
> >> hi Hendri,
>
> >> If I take the where clause out it works and returns all the records.
> >> Tried numerious different combinations to try and put the where clause
> >> in but still returns an error. Works ok using a sql statement in
> >> mysql.
> >> Any other way to count records using where clause.
> >> Thanks again for you time
>
> > I'd say it's this bit:
> > "... = \'en\'"
>
> > Only escape single quotes if they are in a single quoted string.
> > You'd either use:
> > "... = 'en'"
> > Or:
> > '... = \'en\''
>
> > Grtz,

 

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

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