List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:March 5 2003 6:35am
Subject:Re: Count (*) function results needed in echo statement
View as plain text  
At 23:08 -0500 3/4/03, Stitchin' wrote:
>I've got the following code in my php file:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
>  /* Select all categories from designcatagories table */
>   $query = "SELECT designcatagories.catcode, designcatagories.catdesc,
>count(*) FROM
>             designs,designcatagories where designs.catcode =
>designcatagories.catcode
>             GROUP BY catcode";
>   $result = mysql_query($query)
>        or die ("Couldn't execute query.");
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>I tested it in phpMyAdmin and I'm getting the correct results .... here's my
>dilemma ... I want to spit out a list of my catcodes, # designs found,
>catdesc
>and I'm not sure how to reference the count(*) object??? What I have below
>doesn't work, it just prints the () and I can't find any reference to this
>in my books??? HELP!!!

This is not surprising, because you haven't fetched any results.  You've
only executed the query.

while (list ($catcode, $catdesc, $count) = mysql_fetch_row ($result))
{
     # do something with your variables
}
mysql_free_result ($result);


>
>  echo "><b>$catcode</b></font>
>           </td>
>	    <td>$count()</td>
>           <td>$catdesc</td>
>           </tr>";
>
>Renee Toth
>Stitchin' Up A Storm
>www.stitchinupastorm.com

Thread
Count (*) function results needed in echo statementStitchin'5 Mar
  • RE: Count (*) function results needed in echo statementSqlcoders.com Programming Dept5 Mar
    • RE: Count (*) function results needed in echo statementStitchin'5 Mar
  • Re: Count (*) function results needed in echo statementPaul DuBois5 Mar
  • RE: Count (*) function results needed in echo statementJohn Berman5 Mar