我想显示我的SAW代码的结果,但是当我加载它时,它仅显示“您提交的查询无效”。然后,如果我使用implode
来收集$skill
之类的变量,那么我将收到诸如“ unifined index skill”的错误消息。请帮助我。
这是SAW代码
// collect skill
$skill = array();
$sk = $_POST["skill"];
foreach ($sk as $sek) {
array_push($skill, "'".$sek."'");
}
$skills = implode(",",$skill);
// collect nilai
$nilai = $this->input->post("nilai");
//collect gaji
$gaji = $this->input->post("gaji");
// collect Lokasi
$lokasi = ($this->input->post("lokasi") == "0" ? false : true);
// collect jurusan
$jurusan = $this->input->post("jurusan");
$sql = $this->model_data->getRating($skills, $nilai, $gaji, $lokasi, $jurusan);
$result = $this->db->query("$sql")->result();
$saw = new Algoritma();
// menambahkan Kriteria
$saw->addCriteria("skill",$this->input->post("bobot_skill")/100,"1");
$saw->addCriteria("nilai",$this->input->post("bobot_nilai")/100,"0");
$saw->addCriteria("gaji",$this->input->post("bobot_gaji")/100,"0");
$saw->addCriteria("lokasi",$this->input->post("bobot_lokasi")/100,"1");
$saw->addCriteria("jurusan",$this->input->post("bobot_jurusan")/100,"1");
foreach ($result as $hasil) {
$alt = new Alternative("$hasil->kode_lowongan","$hasil->nama_perusahaan");
$alt->addCriteria("skill",$hasil->skill);
$alt->addCriteria("nilai",$hasil->nilai);
$alt->addCriteria("gaji",$hasil->gaji);
$alt->addCriteria("lokasi",$hasil->lokasi);
$alt->addCriteria("jurusan",$hasil->jurusan);
$saw->addAlternative($alt);
}
$saw->generate();
$rekomendasi = $saw->data;
for ($i=0; $i < count($rekomendasi); $i++) {
for ($j=($i+1); $j < count($rekomendasi); $j++) {
if($rekomendasi[$i]->preferensi < $rekomendasi[$j]->preferensi){
$temp = $rekomendasi[$i];
$rekomendasi[$i] = $rekomendasi[$j];
$rekomendasi[$j] = $temp;
}
}
}
$data["hasil"] = $rekomendasi;
$this->load->view("home/sawhasil",$data);
}
我使用Codeigniter进行编码。