I am working on Moodle but have a php-mysql related doubt which is turning out to be complicated, thanks to the lack of my knowledge.
I have a query which returns the output fine. Using IF-ELSe condition I need to check if there is a combination of one of the fields containing a string and one of the field containing a number.
The fields I m checking are of the following type in the database table.
element - varchar(255)
value - longtext
This is my query which returns the o/p as mentioned below:
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";
}
}
}
}
Output:
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.
Ideally the output I'm looking forward to see is something like this
IDEAL O/P:
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
My guess is that it isn't recognizing the value field which is a number in my IF--ELSE case and hence always ends up going in the wrong IF part.
Any guesses as to what is happening. Thanks in advance