Tag Archives: php

CodeIgniter Quick Reference

Some of useful functions but not all the time use. Will be a quick reference everytime want to use them.

URI segment

http://example.com/index.php/news/local/metro/crime_is_up
$this->uri->segment(3); //will produce: metro

DB SQL

$query = $this->db->query("YOUR QUERY");

if ($query->num_rows() > 0)
{
        foreach ($query->result() as $row)
        {
                echo $row->title;
                echo $row->name;
                echo $row->body;
        }
}
$this->db->select('title, content, date');
$this->db->from('blogs');
$this->db->join('comments', 'comments.id = blogs.id');
$this->db->where('name !=', $name);
$this->db->where('title', $title);
$query = $this->db->get('mytable');

end

Some other bootstrap-related tools to study

Found some other tools worth exploring

Visual Editor

  • bootply.com – online visual bootstrap editor
  • pingendo – free, native (download and install)
  • pinegrow.com – paid (starts at usd49), native + online demo
  • layoutit – free, online editor
  • jetstrap.com – paid

Snippets, tools, themes etc.

  • bootsnipp.com – snippets, form builder
  • startbootstrap.com – theme and templates

Others

  • bootstrap magic – change theme, color and other default look for bootstrap based on your preference
  • codiqa.com – build mobile app easily. nice and easy interface
  • x-editable – library to easily update data in-line without whole form submission
  • bootbundle.com – theme, template, plugins etc. many sites on one.
  • list of more plugins and tools

Sample use of CI query builder for CRUD

Sample insert

$data = array(
        'title' => $title,
        'name' => $name,
        'date' => $date
);

$this->db->insert('mytable', $data);

Sample update

$this->db->update('mytable', $data, "id = 4"); OR
$this->db->update('mytable', $data, array('id' => $id));

Sample delete

$this->db->delete('mytable', array('id' => $id));

Sample to get data

$where = "name='Joe' AND status='boss' OR status='active'";
$this->db->where($where);

More on getting data with CI

CI Query builder reference: CI2, CI3

How to easily create PHP image gallery

This becoming my favorite image gallery now – fotorama.io. So easy to implement with plenty of customization that we can do.

If you don’t believe how easy it is, copy following source code, paste and save as an html file. Then open it and see what will happen.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="http://cdnjs.cloudflare.com/ajax/libs/fotorama/4.6.3/fotorama.css" rel="stylesheet">
<script src="http://cdnjs.cloudflare.com/ajax/libs/fotorama/4.6.3/fotorama.js"></script>

<div class="fotorama" data-width="100%" data-ratio="800/600" data-nav="thumbs" data-loop="true" data-allowfullscreen="true">
 <img src="http://s.fotorama.io/1.jpg">
 <img src="http://s.fotorama.io/2.jpg">
</div>