Skip to main content

Posts

Showing posts from March, 2014

jQuery Slidetoggle examples

1.  Simplest Method <script> $(document).ready(function(){   $("button.demo").click(function(){     $(this).parent().find('p').slideToggle("slow");   }); }); </script> HTML <div class="main"> <button class="demo">Toggle slideUp() and slideDown()</button> <p>This is a paragraph.</p> </div> <div class="main"> <button class="demo">Toggle slideUp() and slideDown()</button> <p>This is a paragraph.</p> </div> <div class="main"> <button class="demo">Toggle slideUp() and slideDown()</button> <p>This is a paragraph.</p> </div> 2. Second example <script type="text/javascript"> jQuery(document).ready(function($) {     // Find the toggles and hide their content     $('.toggle').each(function(){         $(this).find('.toggle-content...

How to make alpha-numeric id by given id

How to change number to alpha-numeric function formatPackageNumber ($input) { //$input = $_GET['number'];   $alpha_array = array("A", "B" , "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");   $number_array = array("0", "1" , "2", "3", "4", "5", "6", "7", "8", "9");   $output = "";       for($i=0; $i<=5; $i++){         if($i>=4) {             $divisor = pow(26,$i-3)*pow(10,3);           } else {             $divisor = pow(10,$i);             }       $pos = floor($input/$divisor);        ...

How make redirection by .htaccess file

This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is outside the scope of support provided by (mt) Media Temple. Please take a moment to review the Statement of Support. Instructions 1. Create an empty text file using a text editor such as notepad, and save it as htaccess.txt. NOTE: The reason you should save the file as htaccess.txt is because many operating systems and FTP applications are unable to read or view .htaccess files by default. Once uploaded to the server you can rename the file to .htaccess. 2. Edit the contents of the file. Check the following examples: 301 (Permanent) Redirect: Point an entire site to a different URL on a permanent basis. This is the most common type of redirect and is useful in most situations. In this example, we are redirecting to the "mt-example.com" domain: # This allows you to redirect your entire website to any other domain Redirect 301 / http://mt-example.com/ ...

CakePHP pagination

Paginate provide a set of controls to navigate through paged data. Pagination inside Controller class RecipesController extends AppController {     public $components = array('Paginator');     public $paginate = array(         'limit' => 25,         'contain' => array('Article')     ); } Pagination define inside function public function list_recipes() {     $this->Paginator->settings = $this->paginate;     // similar to findAll(), but fetches paged results     $data = $this->Paginator->paginate('Recipe');     $this->set('data', $data); } You can filter the records by passing conditions as second parameter to the paginate() function: $data = $this->Paginator->paginate(     'Recipe',     array('Recipe.title LIKE' => 'a%') ); Pagination with behaviour  $this->paginate=array('conditions'=...

Php Session

What is a session? A session is basically a way of storing variables and making them available across multiple pages on your web site.  We use the   PHP   super global $_SESSION to hold it. Eg: $_SESSION['variable']   <?php // begin the session session_start ();  // set the value of the session variable $_SESSION [ 'hello' ]= 'sudhir' ;  ?> We can retriew this value on another page by this <?php  // begin our session session_start ();  // echo the session variable echo  'The value of hello is ' . $_SESSION [ 'hello' ] ;  ?> What should I do to destroy a whole session? ...