English 中文(简体)
问询所交回的产出是否含有指示数/编号
原标题:Check if the output returned by a query contains a string/number or not

我在Moodle工作,但有一个php-mysql的相关疑问,由于缺乏我的知识,这些疑问正在变得复杂。

我有一个疑问,即产出罚款回报。 采用I-ELSe条件,需要检查,是否将一个有方位的田地和一个包含多个领域的田地结合起来。

在数据库表中,Im站点检查的类型如下。

 element - varchar(255)
 value - longtext

这是我对如下文所述 o/p的回击:

Query

    $scormstatus = $DB->get_records_sql("SELECT sc.*, s.name AS activityname FROM mdl_scorm_scoes_track AS sc JOIN mdl_scorm AS s ON s.id = sc.scormid WHERE sc.scormid =  " .$activityid. "  AND sc.userid =  " .$userid. "  AND sc.attempt =  ".$scormattempt->attempt." ");
     foreach($scormstatus as $status)
      {
         echo "<br/>".$status->element."**".$status->value."<br/>";
         if(is_numeric($status->value))
         {
           if($status->element =  cmi.core.score.raw  && $status->value !=  0 )
           {
              echo "<br/>Score";
           }    
           else
           {
                if($status->element =  x.start.time  && $status->value !=  0 )
                {
                  echo "<br/>Started";
                }
           }
        }
    }

产出:

         cmi.core.lesson_location**2
         Score

         cmi.core.lesson_status**incomplete
         cmi.core.score.max**50
         Score

         cmi.core.score.min**0
         cmi.core.score.raw**0
         cmi.core.total_time**00:00:22.00

         x.start.time**1334767290
         Score

Now as you would have seen that even though I m checking for a condition which is a combination of cmi.core.score.raw and value greater than 0 it still prints Score for all records and never goes in the else part.

理想的做法是产出 我期待着看到这样的情况。

国际民主和选举援助学会

     cmi.core.lesson_location**2
     cmi.core.lesson_status**incomplete
     cmi.core.score.max**50
     cmi.core.score.min**0
     cmi.core.score.raw**0
     cmi.core.total_time**00:00:22.00
     x.start.time**1334767290
     Started

我的猜测是,承认我在法国-法国-欧洲经济论坛案中的一些价值领域,因此总是在错误的综合框架中结束。

Any guesses as to what is happening. Thanks in advance

最佳回答

该法典:

if($status->element =  cmi.core.score.raw 

需要:

 if($status->element ==  cmi.core.score.raw 

单一<代码>=为转让,而两个<代码>=为比较。

问题回答

暂无回答




相关问题
Simple JAVA: Password Verifier problem

I have a simple problem that says: A password for xyz corporation is supposed to be 6 characters long and made up of a combination of letters and digits. Write a program fragment to read in a string ...

Case insensitive comparison of strings in shell script

The == operator is used to compare two strings in shell script. However, I want to compare two strings ignoring case, how can it be done? Is there any standard command for this?

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

String initialization with pair of iterators

I m trying to initialize string with iterators and something like this works: ifstream fin("tmp.txt"); istream_iterator<char> in_i(fin), eos; //here eos is 1 over the end string s(in_i, ...

break a string in parts

I have a string "pc1|pc2|pc3|" I want to get each word on different line like: pc1 pc2 pc3 I need to do this in C#... any suggestions??

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签