I have this code in my model file
function exist_kode($kode = 1)
{
$get = $this->db->query("SELECT * FROM perkiraan WHERE kode_perk='$kode'");
if($get->num_rows() == 0)
{
return $kode;
}
else
{
$this->exist_kode((int)$kode+1);
}
}
This function is not return some values when I use. But if I change return to echo, it will write the value I hope.
How can i solve this?
Return in your else statement as well:
return $this->exist_kode((int)$kode+1);