lingo5 Posted October 12, 2012 Share Posted October 12, 2012 Hi, this is my query here $colname_cats_RS = "-1"; if (isset($_GET['id_categoria'])) { $colname_cats_RS = $_GET['id_categoria']; } mysql_select_db($database_MySQLconnect, $MySQLconnect); $query_cats_RS = sprintf("SELECT * FROM t_subcategorias WHERE id_categoria = %s", GetSQLValueString($colname_cats_RS, "int")); $cats_RS = mysql_query($query_cats_RS, $MySQLconnect) or die(mysql_error()); $row_cats_RS = mysql_fetch_assoc($cats_RS); $totalRows_cats_RS = mysql_num_rows($cats_RS); and this is how I echo the results <?php echo $row_cats_RS['subcategoria_esp']; ?> What I need to do is to display the record count for each subcategory like for example: red (5) blue(2) etc.... Please help me :-) Link to comment https://forums.phpfreaks.com/topic/269388-please-help-counting-records/ Share on other sites More sharing options...
kicken Posted October 12, 2012 Share Posted October 12, 2012 Use a JOIN to link up to which ever table you need to count the values in, then use the sql function COUNT() and the GROUP BY clause to select a list of categories and their counts. You'll have to post the structure of your tables if you need help figuring out how to do the join. Link to comment https://forums.phpfreaks.com/topic/269388-please-help-counting-records/#findComment-1384766 Share on other sites More sharing options...
Eritrea Posted October 13, 2012 Share Posted October 13, 2012 use the mysql built-in COUNT function, it is very easy. check out tzag.com Link to comment https://forums.phpfreaks.com/topic/269388-please-help-counting-records/#findComment-1384958 Share on other sites More sharing options...
lingo5 Posted October 14, 2012 Author Share Posted October 14, 2012 kicken and Eritrea, sorry I missed your replies....will try both your suggestions and come back ...thanks Link to comment https://forums.phpfreaks.com/topic/269388-please-help-counting-records/#findComment-1385129 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.