Jump to content

ksort not working


Nodral

Recommended Posts

Hi

 

I have the following code and all is working except the ksort.  If i remove it I get a list of approx 100 users with different userid's in no particular order.  If I leave the ksort in, I get no user list.  Any ideas?

 

require_once "../config.php";
$sql = 'SELECT * FROM `mdl_scorm_scoes_track` WHERE scormid =338 AND element = "cmi.core.lesson_status"';
$sql = mysql_query($sql);
while ($row = mysql_fetch_array($sql)){
switch($row['value']){
	case "passed":
		$passed ++;
	break;
	case "completed":
		$completed++;
	break;
	case "incomplete":
	$getuser="SELECT firstname, lastname from mdl_user WHERE id = " . $row['userid'];
	$getuser=mysql_query($getuser);
	$getuser=mysql_fetch_array($getuser);
	$getuser = $getuser['firstname'] . " " . $getuser['lastname'] . " " . $row['userid'];
	$userfail[$row[userid]]=$getuser;
	break;
	default:
		$other++;
	break;
}
}
$total = $passed + $incomplete + $completed;
$incomplete = count($userfail);
$total = $passed + $incomplete + $completed;
$userfail=ksort($userfail);
echo "Status showing as Completed (100% in test) = $completed out of $total<br/>";
echo "Status showing as Passed (80% in test) = $passed out of $total<br/>";
echo "Status showing as Incomplete (60% or less or not finished module) = $incomplete out of $total<br/>";
foreach ($userfail as $value){
echo "$value <br/>";
}

Link to comment
https://forums.phpfreaks.com/topic/234229-ksort-not-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.