Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
一个简单的PHP问题_Php_Joomla - Fatal编程技术网

一个简单的PHP问题

一个简单的PHP问题,php,joomla,Php,Joomla,我有一个Joomla模块,它基本上显示类别列表。在类别名称旁边,使用下面的行显示特定类别中的项目数 <em>(<?php echo $row->counter ;?>) </em> () 类别中的项目被设置为“打开”、“关闭”或“冻结”,我正在尝试使其仅显示“打开”项目的数量,而不包括任何关闭或冻结的项目 <?php // no direct access defined('_JEXEC') or die('Restricted acc

我有一个Joomla模块,它基本上显示类别列表。在类别名称旁边,使用下面的行显示特定类别中的项目数

 <em>(<?php echo $row->counter ;?>) </em>  
()
类别中的项目被设置为“打开”、“关闭”或“冻结”,我正在尝试使其仅显示“打开”项目的数量,而不包括任何关闭或冻结的项目

<?php

// no direct access
defined('_JEXEC') or die('Restricted access'); 

$document =& JFactory::getDocument();
$html = '<link href="'.JURI::base(). 'modules/mod_glance_categories/css/style.css" rel="stylesheet" type="text/css" />';
$document->addCustomTag( $html );

$n = 0;
if(count($rows) > 0){

?>
<table width="100%" cellpadding="0" cellspacing="0">
<?php
foreach ( $rows as $row ) 
{
 $n++;
if($n ==1){?>
<tr>   
<?php 
}
if($n <= $columns){
?>
 <td align="left" valign="top" >
 <?php $link_proj_categ = JRoute::_('index.php?option=com_glance&task=categproj&id='.$row->id);?>
 <a href="<?php echo $link_proj_categ;?>" class="tpf_tcatnode">
 <strong><?php echo $row->categories; ?></strong>
 <em>(<?php echo $row->counter ;?>) </em>
 </a>
  </td>
 <?php 
 }
 if($n == $columns){?>
  </tr> 
  <?php 
 $n =0;
   }  
}
$n++;
if($n <= $columns){
 for($x=$n;$x<=$columns;$x++){?>
  <td>&nbsp;</td>
 <?php
}?> 
 </tr> 
 <?php 
 } ?>

  </table>
  <?php } ?>

如果您想要“If the status is open”,那么您的If语句应该如下所示:

if(count($rows) > 0 && ($row->status) == "open"){
      // Do something
}

但是,在您的代码中有$n,这是未使用的$行和$row未初始化$rows和$row是不同的变量(我希望您理解这一部分)

如果没有更多细节,我会说你的答案如下:(我假设条件中的两个变量应该是相同的。)


什么是状态,一个字符串?什么是
$n
?如果(count($rows)>0)和($row->status)>open){-也许应该是如果(count($rows)>0)和($row->status)>$open){我同意锁。除非open是一个常量,否则它需要一个“$”。一些设置会假设它应该是“open”,但>不适合进行字符串比较。感谢您的快速响应。我尝试了上述所有操作,但始终返回解析错误:语法错误、意外的T_BOOLEAN_和in blah/blah/I明显缺少一些内容?您的括号没有对齐。您的括号没有对齐。在我编写它时,问题是错误的。感谢您的关注顺便提一下
if(count($rows) > 0 && $rows->status) == "open"){
if(count($rows) > 0 && $rows[0]->status == "open"){
if(count($rows) > 0 && $rows['status'] == "open"){
if(count($rows) > 0 && $rows[0]['status'] == "open"){