Showing posts with label codeigniter. Show all posts
Showing posts with label codeigniter. Show all posts

Friday 16 September 2016

How to fetch title of an product name from a database and send it to the header template in CodeIgniter

How to fetch title of an product name from a database and send it to the header template in CodeIgniter

Hello

If you want product name title in header title then follow this in incrustation.

In Model

function get_prductname($pid)
{
    $query = $this->db->query("SELECT * FROM table_name WHERE pid= '$pid' ");
   
    $count = count($result); # New

    return  $result = $query->row();
}
 
In Controller
 
public function prodcudetail($pid)
{
    $result = $this->Listing_model->get_prductname($pid); # Changed

    $data["page_title"] = $result[0]['field_name']; # Changed

        $this->load->view('includes/header',$data); # Changed
        $this->load->view('listings/listing_card',$data);
        $this->load->view('includes/footer');

}  
 
In View
 
php echo (!empty($page_title->productname)) ? $page_title->productname : ''; ?> # Changed   
 
This example of how setup  product name from a database and send it to the header template in CodeIgniter

How to manange two different codeigniter session value in localhost?

Hello

Here issue If we Install Two codeigniter in localhost then some time session value config with another codeigniter .

for example

I Have to develope two different different site in login query i am create user_login session for two website same. one site login  it's effect to another site

if one of site logout then second website automatically logout.

for this issue we have to manage config file.

all website set in config file this

$config['sess_cookie_name'] = 'you own name for the session';
 
 


Wednesday 29 June 2016

Displaying a flash message after redirect in Codeigniter

Displaying a flash message after redirect in Codeigniter


In Your Controller set this
<?php

public function change_password(){







if($this->input->post('submit')){
$change = $this->common_register->change_password();

if($change == true){
$messge = array('message' => 'Password chnage successfully','class' => 'alert alert-success fade in');
$this->session->set_flashdata('item', $messge);
}else{
$messge = array('message' => 'Wrong password enter','class' => 'alert alert-danger fade in');
$this->session->set_flashdata('item',$messge );
}
$this->session->keep_flashdata('item',$messge);



redirect('controllername/methodname','refresh');
}

?>

In Your View File Set this
<script type="application/javascript">
/** After windod Load */
$(window).bind("load", function() {
  window.setTimeout(function() {
    $(".alert").fadeTo(500, 0).slideUp(500, function(){
        $(this).remove();
    });
}, 4000);
});
</script>

<?php

if($this->session->flashdata('item')) {
$message = $this->session->flashdata('item');
?>
<div class="<?php echo $message['class'] ?>"><?php echo $message['message']; ?>

</div>
<?php
}

?>

Tuesday 3 March 2015

How To create Pagination in codeigniter

How To create Pagination in codeigniter



Here I am Create Pagination Example in Codeigniter.

The Model


create model Model/news_model.php

provide a count of all the records in the News table, and retrieve a list of news from the table

The record_count() method returns the number of records and is needed because one of the options in the $config array for the pagination library is $config["total_rows"]

The get_news() method retrieves a list of all the records from the News table.
there are two arguments $start, $limit.
The arguments will be set in the controller.

How to create custom library in CodeIgniter


How to create custom library in CodeIgniter


We are normally referring to the classes that are located in the libraries directory.
You can create your own libraries within your application/libraries directory.

Here
1)You can replace native and extend libraries.
2) You can create new libraries.