php - concat the two id came from database in ajax and codeigniter -
i having trouble in concating value of 2 id's database generate new id , use save again in database. using codeigniter , want technique/way concat better result or maybe faster. having problem, whenever there value in database, cannot increment id having +1. got output of 1-undefine-1
here ajax:
function getcheckupid() { var init = 0; var value = $('#clinicid').html(); $.ajax ({ url: siteurl+"myclinic/getcheckid", type: "get", datatype: "json", success: function(data) { if(data.length>0) { $('#checkid').text(value+"-"+data[0]['clinic_id']+1); $("#checkid").css('visibility','visible'); } else { $('#checkid').text(value+"-"+init); $("#checkid").css('visibility','visible'); } } }) } function get_clinicid() { $("#clinicid").empty(); $.ajax({ url: siteurl+"myclinic/get_clinicid", type: "get", datatype: "json", success: function(data) { $('#clinicid').text(data[0]['clinic_id']); } }); }
i check records in db using if(data.length>0)
if got record, go data , +1 it. got value of undefined, if goes else, outputs bad, because whenever refresh it. outputs - 0, want 1-0. refresh again. how can concat safely ? issue in ajax ?. making slow ?
here controller :
public function getcheckid() { $checkid = $this->clinic_model->checkupid(); echo json_encode($checkid); }
my model :
public function checkupid() { $query = $this->db->query('select tbl_check_up.check_up_id tbl_check_up'); return $query->result(); }
Comments
Post a Comment