Skip to main content

Posts

jQuery Autocomplete

<link rel="stylesheet" type="text/css" href="/css/jquery.autocomplete.css" /> <script src="js/jquery/jquery-1.7.1.min.js"></script> <script src="js/jquery/jquery.ui.autocomplete.min.js"></script> jQuery autocomplete with jSON <script>var data = [ {"label" : "Aragorn"}, {"label" : "Arwen"}, {"label" : "Bilbo Baggins"}, {"label" : "Boromir"}, {"label" : "Frodo Baggins"}, {"label" : "Gandalf"}, {"label" : "Gimli"}, {"label" : "Gollum"}, {"label" : "Legolas"}, {"label" : "Meriadoc Merry Brandybuck"}, {"label" : "Peregrin Pippin Took"}, {"label" : "Samwise Gamgee"} ]; </script> <script> $(function() { $( ...

Cakephp Model Attributes

useDbConfig: The useDbConfig property is a string that specifies the name of the database connection to use to bind your model class to the related database table. Example usage: class Example extends AppModel {     public $useDbConfig = 'alternate'; } useTable: The useTable property specifies the database table name. class Example extends AppModel {     public $useTable = false; // This model does not use a database table } Alternatively: class Example extends AppModel {     public $useTable = 'exmp'; // This model uses a database table 'exmp' } Order The default ordering of data for any find operation. Possible values include: $order = "field" $order = "Model.field"; $order = "Model.field asc"; $order = "Model.field ASC"; $order = "Model.field DESC"; $order = array("Model.field" => "asc", "Model.field2" => "DESC"); virtualFields Array of virtual fields this model h...

Pagination with MySql, jQuery & Php

Ajax pagination with MySQL, PHP and jQuery Method 1: Javascript : <script type="text/javascript"> $(document).ready(function(){ function loading_show(){ $('#loading').html("<img src='images/loading.gif'/>").fadeIn('fast'); } function loading_hide(){ $('#loading').fadeOut('fast'); }                 function loadData(page){ loading_show();                     $.ajax ({ type: "POST", url: "load_data.php", data: "page="+page, success: function(msg) { $("#container").ajaxComplete(function(event, request, settings) { loading_hide(); $("#container").html(msg); }); } }); } loadData(1);  $('#container .pagination li.active').on('click',function(){ var page = $(this).attr('p'); loadData(page); }); }); </script> ...

Export CSV in cakephp

1. Download XLS sheet in CakePHP In the controller function function downloadXLS(){         $this->set('contacttracker', $this->paginate()); $this->layout = false; header ("Expires: Mon, 28 Oct 2008 05:00:00 GMT"); header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT"); header ("Cache-Control: no-cache, must-revalidate"); header ("Pragma: no-cache"); header ("Content-type: application/vnd.ms-excel"); header ("Content-Disposition: attachment; filename=contacts_".date('d-m-Y').".xls"); header ("Content-Description: Generated Report" ); } In the view section download_xls.ctp <STYLE type="text/css"> .table{font-family:arial; font-size:12px;} .tdheading{font-weight:bold;color:#fff;background-color:#2E2E2E;border-width: 0.5pt;border: solid;border-color:#fff; } .tdcontent{border-width:0.5pt; border: solid;} ...

Cakephp Html Helper

Meta Tag <? php   echo   $this -> Html -> charset ();   ?> Will output: < meta   http - equiv = "Content-Type"   content = "text/html; charset=utf-8"   /> Link Tag <? php   echo   $this -> Html -> link (      'Delete' ,      array ( 'controller'   =>   'recipes' ,  'action'   =>   'delete' ,  6 ),      array (),      "Are you sure you wish to delete this recipe?" ); ?> Will output: < a   href = "/recipes/delete/6"   onclick = "return confirm('Are you sure you wish to delete this recipe?');" > Delete </ a > Creating Table header <?php   echo   $this -> Html -> tableHeaders (      array ( 'Date' , 'Title' , 'Active' ),      array ( 'class'   =>   'status' ),   ...