我有一个简单的逻辑可以对标签进行排序并为其分配标签
但有时显示Undefined variable
:predikat_cluster2
错误
您能指出我的错误吗?我很抱歉要问这样的琐碎事情,但是我对此很新
谢谢。
$rata_rata1 = '';
$rata_rata2 = '';
$rata_rata3 = '';
$predikat_cluster1 ='';
$predikat_cluster2 ='';
$predikat_cluster3 ='';
foreach($centroidcluster->result() as $h)
{
$rata_rata1 = $h->centroid1cluster1_baru;
$rata_rata2 = $h->centroid1cluster2_baru;
$rata_rata3 = $h->centroid1cluster3_baru;
}
////PREDIKAT CENTROID 1
if($rata_rata1 > $rata_rata2&& $rata_rata1 > $rata_rata3){
$predikat_cluster1 = "Sangat Baik";
}
elseif($rata_rata1> $rata_rata2&& $rata_rata1 < $rata_rata3)
{
$predikat_cluster1 = "Baik";
}
elseif($rata_rata1 < $rata_rata2&& $rata_rata1 < $rata_rata3)
{
$predikat_cluster1 = "Cukup Baik";
}
if($rata_rata2 > $rata_rata3&& $rata_rata2 > $rata_rata1){
$predikat_cluster2 = "Sangat Baik";
}
elseif($rata_rata2> $rata_rata3&& $rata_rata2 < $rata_rata1)
{
$predikat_cluster2 = "Baik";
}
elseif($rata_rata2 < $rata_rata3&& $rata_rata2 < $rata_rata1)
{
$predikat_cluster2 = "Cukup Baik";
}
if($rata_rata3 > $rata_rata2&& $rata_rata3 > $rata_rata1){
$predikat_cluster3 = "Sangat Baik";
}
elseif($rata_rata3 > $rata_rata2&& $rata_rata3 < $rata_rata1)
{
$predikat_cluster3 = "Baik";
}
elseif($rata_rata3 < $rata_rata2&& $rata_rata3 < $rata_rata1)
{
$predikat_cluster3 = "Cukup Baik";
}
?>