In this example i am going to show you how to get the last insert id after insert data in database.
insert_id() function will return zero if table does not have auto incremented column so make sure table must have a column with AUTO_INCREMENT attribute.