Get the Last added ID and Insert it to another Table as a foreign key

Get the last id from the database:-


Suppose I have two table ‘product_sale’ and ‘customer_information’. I want to get last id from the ‘product_sale’ table and insert it to ‘customer_information’ table as a foreign key.

public function insertProductsale($data, $data_c) {

$this->db->insert('product_sale', $data);
$sale_id = $this->db->insert_id();
$data_c['sale_id'] = $sale_id;
return $this->db->insert('customer_information', $data_c);

CodeIgnier pagination CSS Style

We always use pagination in most of the part of a Custom CMS and other where you need. But sometime we don’t have enough time to create a nice style in the pagination links. Now I just share with all to some style css code. So just copy and paste and got a nice style in Pagination Anchor tag.

<style type="text/css">

#pagination a, #pagination strong {
background: #e3e3e3;
padding: 4px 7px;
font-size: 13px;
text-decoration: none;
border: 1px solid #eac9c9;
color: #292929;

#pagination strong, #pagination a:hover{
font-weight: normal;
background: #AFAFAF;

table {
margin-bottom: 30px;


<div id="pagination">
echo $this->pagination->create_links();