[eluser]sofwan[/eluser]
You don't need to make 2nd views, just using 1 view, 1 variable but different value. One value is for filled data, another for empty data.
I have an example :
Model :contoh.php
<?php
class Contoh extends model
{
function tampil()
{
$query="select * from countries where value='Endonesia'";
$hasil=$this->db->query("$query");
return $hasil;
}
}
?>
Controller :contoh_contr.php
<?php
class Contoh_contr extends Controller
{
function contoh_contr()
{
parent::controller();
$this->load->model("contoh");
}
function index()
{
$hasil=$this->contoh->tampil();
if ($hasil->num_rows()>0)
{
$hasilnya=$hasil->row();
$data["negara"]=$hasilnya->value;
}
else
{
$data["negara"]="No country";
}
$this->load->view("tampil_hasil",$data);
}
}
?>
View : tampil_hasil.php
<?php
echo "Nama Negara : $negara";
?>
But for another example, getting an array of a table, it results 2 different kind values, one is array (Data is exist) another is a single variable (No data inside). You can add if .. else in your view to display the value.