Show number of labels

3 posts by 2 authors in: Forums > CMS Builder
Last Post: April 3, 2013   (RSS)

By rui - April 3, 2013

Hi from Portugal,

I´m trying to show the number of labels based on a keyword.

Here is my setup:
---------------------------------------------------------
Artist title
Music category
   - Radio button (classic)
   - Radio button (rock)
   - Radio button (techno)
Text
---------------------------------------------------------

On the website i have the categories like this:

what i have:
---------------------------------------------------------
Classic (number here)  Rock (number here)  Techno (number here)
---------------------------------------------------------

what i want:
---------------------------------------------------------
Classic (24)  Rock (12)  Techno (16)
---------------------------------------------------------


My problem is i want to show the number of labels for category. The code i have is this:

Record Number: <?php echo htmlencode($record['num']) ?><br/>
Category (value): <?php echo $record['category'] ?><br/>
Category (label): <?php echo $record['category:label'] ?><br/>
title: <?php echo htmlencode($record['title']) ?><br/>
Text: <?php echo htmlencode($record['text']) ?><br/>
_link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>

I want to make a count of articles that have a category radio button keyword like CLASSIC.
I dont know if i explain my self very well.... sorry my english.

Can someone help me?

By Djulia - April 3, 2013 - edited: April 3, 2013

Hi Rui,

Jason suggests a solution here:
http://www.interactivetools.com/forum/forum-posts.php?postNum=2213208

<select>
<option value="?">My list</option>
  <?php foreach (getListOptions('myTableName','myFieldName') as $value => $label): ?>
  <?php $lisitingCount = mysql_count('myTableName', "myFieldName= '$value'"); ?>
    <option value="<?php echo $value; ?>" <?php selectedIf($value, @$_REQUEST['format']); ?>><?php echo $label; ?> - <?php echo $lisitingCount;?></option>
  <?php endforeach; ?>
</select>

<ul>
  <?php foreach (getListOptions('myTableName','myFieldName') as $value => $label): ?>
  <?php $lisitingCount = mysql_count('myTableName', "myFieldName= '$value'"); ?>
   <li><?php echo $label; ?> - <?php echo $lisitingCount;?></li>
  <?php endforeach ?>
</ul>

I hope this helps!

Djulia