RE: [PHP] database value count retrieval

From: Date: Mon, 19 Aug 2002 23:57:52 +0000
Subject: RE: [PHP] database value count retrieval
Groups: php.general 
Request: Send a blank email to php-general+get-113275@lists.php.net to get a copy of this message
try this: -> $sqlcom="select count(codigo) as cnt from comments where codigo=$id"; $resultadocom = mysql_db_query ("database",$sqlcom); $registocom = mysql_fetch_array($resultadocom); -> $contador = $registocom["cnt"]; print("comentarios= $contador"); the lines marked with -> are the lines I changed -----Original Message----- From: Pag [mailto:dante@mail.telepac.pt] Sent: Tuesday, August 20, 2002 9:38 AM To: php-general@lists.php.net Subject: [PHP] database value count retrieval >SELECT COUNT(x) FROM table; > >Make 'x' equal to any column name in the table and add WHERE to the >clause as needed. err...all very well, but how do i retrieve the value afterwards? Heres my code: $sqlcom="select count(codigo) from comments where codigo=$id"; $resultadocom = mysql_db_query ("database",$sqlcom); $registocom = mysql_fetch_array($resultadocom); $contador = $registocom["codigo"]; print("comentarios= $contador"); Nothing comes out, although i dont have a clue on how to retrieve the result after the fetch_array. :-P /Pag -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#113275) next »