Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.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 如果用户的行包含值,则回显html_Php_If Statement_Joomla_Echo - Fatal编程技术网

Php 如果用户的行包含值,则回显html

Php 如果用户的行包含值,则回显html,php,if-statement,joomla,echo,Php,If Statement,Joomla,Echo,我在Joomla网站上工作,当用户完成某个程序中的某个测验时,我想在他们的个人资料中显示验证图形和文本。我已经完成了大部分代码,但我无法让它完成我想要的。以下是我所拥有的: $db = &JFactory::getDBO(); $uri = JURI::base(); $my =& JFactory::getUser(); $user =& CFactory::getActiveProfile(); $quer

我在Joomla网站上工作,当用户完成某个程序中的某个测验时,我想在他们的个人资料中显示验证图形和文本。我已经完成了大部分代码,但我无法让它完成我想要的。以下是我所拥有的:

$db = &JFactory::getDBO(); $uri = JURI::base(); $my =& JFactory::getUser(); $user =& CFactory::getActiveProfile(); $query = 'select distinct(a.id), a.title, a.alias, a.description, a.created, a.responses, c.title as category' . ' from #__quiz_quizzes a left join #__quiz_categories c on a.catid=c.id left join #__quiz_responses r on a.id=r.quiz_id' . ' where r.created_by='.$user->id.' and a.published=1 order by a.created desc'; $db->setQuery($query, 0, 10); $items = $db->loadObjectList(); $menu = &JSite::getMenu(); $mnuitems = $menu->getItems('link', 'index.php?option=com_communityquiz&view=quiz'); $itemid = isset($mnuitems[0]) ? '&Itemid='.$mnuitems[0]->id : ''; if (strpos($itemid,'3')) { echo " Rep is Verified"; } else { echo " Rep is not Verified {SHOW_FOR profile_owner} How to get verified{/SHOW_FOR}{HIDE_FOR profile_owner} What does this mean?{/HIDE_FOR}"; echo ""; } 问题是,如果有人用id“3”参加了测试,它会说他们已经被验证了。如果quick_id等于'3',并且created_by字段与$user匹配,我需要它只显示已验证的部分。我的代码是从原来的插件和它的所有可能甚至不需要这样一个小功能,帮助简化将不胜感激!

我想我是在Stack Overflow上结合其他论坛条目找到的。这项工作:

    $user   =& CFactory::getActiveProfile();
    $result = mysql_query("SELECT COUNT(*) AS num_rows FROM hxlth_quiz_responses WHERE created_by='{$user->id}' and quiz_id='3' and score='3' LIMIT 1;");
    $row = mysql_fetch_array($result);
    if($row["num_rows"] > 0){
    echo "<div style='margin: 0 15px 15px 0; padding: 5px; box-shadow: rgba(0,0,0,0.4) 1px 1px; border: 1px solid #cccccc;'><img src='/images/check1.jpg' align='absmiddle' width='22' height='21' /> Rep is Verified</div>";
    } else {
    echo "<div style='margin: 0 15px 15px 0; padding: 5px; box-shadow: rgba(0,0,0,0.4) 1px 1px; border: 1px solid #cccccc;'><img src='/images/x1.jpg' align='absmiddle' width='21' height='21'> Rep is not Verified {SHOW_FOR profile_owner}<a href='index.php?option=com_communityquiz&view=quiz&task=respond&id=3'><font size='1'> How to get verified</font></a>{/SHOW_FOR}{HIDE_FOR profile_owner} <a href='index.php?option=com_communityquiz&view=quiz&task=respond&id=3'><font size='1'> What does this mean?</font>{/HIDE_FOR}";
    echo "</a></div>";
    }
现在它正确地显示了图形和文本,我甚至加入了一个和分数变量,以确保他们真正通过了测验