我在 PHP 语句中有这个查询foreach
:
<?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;?>
如何从 MySQL 数据库中检索每个“列表”的内容 ID?
$query = "SELECT COUNT(product) FROM my_table WHERE contentid = '**I want content id here**'";
我正在使用 joomla 2.5 和 Jreviews。<?php echo $listing['Listing']['listing_id'];?>
列表 id在foreach
语句中被“调用” 。