Jump to content


Photo

how to count results?


  • Please log in to reply
3 replies to this topic

#1 feri_soft

feri_soft
  • Members
  • PipPipPip
  • Advanced Member
  • 147 posts

Posted 29 April 2006 - 05:55 AM

How to coun t results in mysql and display the number of the results.Something like numrows???How exactly

#2 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 29 April 2006 - 05:58 AM

SELECT COUNT('some_field_name') FROM `some_table_name` AS total WHERE ...

or were you looking for msql_num_rows()?

#3 feri_soft

feri_soft
  • Members
  • PipPipPip
  • Advanced Member
  • 147 posts

Posted 29 April 2006 - 10:58 AM

I think it is:
msql_num_rows()

because i want for example to show how many results there are.I have category design lets say and on the left i want to know how many are the articles in it.I use this

"Select * from articles where cat_id=...."

And then how to show how many are the articles from this category ;)

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 29 April 2006 - 12:13 PM

In mysql:
<?php
$q = "Select * from articles where cat_id=....";
$rs = mysql_query($q) or die('Problem with query: ' . $q . '<br>' . mysql_error());
$n = mysql_num_rows($rs);
echo $n;
?>

Ken





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users