I have this query in a PHP foreach
statement:
<?php $i = 2; $j = 0; foreach($listings AS $listing): $i = $i == 2 ? 1 : 2;?>
...
<?php
$db =& JFactory::getDBO();
$query = "SELECT COUNT(product) FROM my_table WHERE contentid = 'I want content id here'";
$db->setQuery($query);
$count = $db->loadResult();
echo ($count); //this print the count
?>
...
<?php endforeach;?>
How can I retrieve content id for each "listing" from MySQL database?
$query = "SELECT COUNT(product) FROM my_table WHERE contentid = '**I want content id here**'";
I'm using joomla 2.5 and Jreviews. The listing id is "called" by <?php echo $listing['Listing']['listing_id'];?>
into the foreach
statement.