Thursday 28 August 2014

Add Drop Down to Yii Grid


Add  Drop Down to Yii Grid

$myColumns [] = array(
    'type' => 'raw',
    'header' => "Page Size",
'filter' => CHtml::dropDownList('pageSize', $pageSize, Yii::app()->params['defaultPageDdSize'], array('style' => 'font-size:11px; width: 50px; padding: 0px 0px 0px 0px; height: initial; ',)),
      'value' => '"<a href=\'javascript:void(0);\' onclick=\'renderView(".$data->id_games.")\' class=\'view\' data-toggle=\'tooltip\' title=\'\' data-original-title=\'View\'>
                  <i class=\'icon-eye-open\'></i></a> &nbsp;
      <a href=\'' . Yii::app()->controller->createUrl('update&id=$data->id_games') . '\' class=\'update\'  data-toggle=\'tooltip\' title=\'\' data-original-title=\'Update\'>
        <i class=\'icon-pencil\'></i></a> &nbsp;
<a class=\'delete\' onclick=\'renderDeleteForm(".$data->id_games.")\' data-toggle=\'tooltip\' title=\'\' data-original-title=\'Delete\'>
        <i class=\'icon-trash\'></i></a>
"',
    'htmlOptions' => array('class' => 'button-column','style' => 'width:62px')
);

Monday 18 August 2014

Get the count of records from a table in yii


Get the count of records from a table .
The best of way of retrieving the count of a query in yii.

For all record
$sql = "SELECT COUNT(*) FROM tablename;
$numRecordsFound = Yii::app()->db->createCommand($sql)->queryScalar();

For Criteria Based record.

$sql = "SELECT COUNT(*) FROM tablename where columnName=".$columnValue;
$numRecordsFound = Yii::app()->db->createCommand($sql)->queryScalar();

Monday 11 August 2014

Window.location.href () and Window.open () methods in JavaScript


window.location.href is not a method, it's a property that will tell you the current URL location of the browser. Setting the property to something different will redirect the page.

window.open() is a method that you can pass a URL to that you want to open in a new window. For
example:
window.location.href example:
window.location.href = 'phplessonstips.blogspot.in'; //Will take you to phplessonstips blog.
window.open() example:

window.open('phplessonstips.blogspot.in'); //This will open phplessonstips.blogspot.in in a new window.

Thursday 7 August 2014

How to get the day name from the date in php

If you solution for getting a day name from any past of future day, You are at right page of web.
Use below code.

<?php
$date  = '12-Jul-2014'; // Use any valid PHP date format
$timestamp = strtotime($date);
echo 'Short Name of Day => '. $day = date('D', $timestamp); //Short Name of Day => Sat
echo '<br> Full Name of Day => '. $day = date('l', $timestamp); //Full Name of Day => Saturday
?>


Wednesday 6 August 2014

Check page is home page or not in Joomla

This is the code which you have to write in files where you want to check for Joomla home page

$menu = & JSite::getMenu();
if ($menu->getActive()   == $menu->getDefault()) {
   echo "Home page";
} else {
   echo "Other page";
}

Joomla 2.5 Component Creation

If you want to create component in joomla 2.5 following steps are require I create just simple code for that

Steps
Remember that the folder name which you given com_student means student will you have to given in files In that .xml file is main file in which you have to give the files and folder path and component settings
  1. Create a folder for which you want to create component like For student : com_student
  2. Following are folder hierarchy
    student.xml
    site/student.php
    site/index.html
    admin/index.html
    admin/student.php
    admin/sql/index.html
    admin/sql/updates/index.html
    admin/sql/updates/mysql/index.html
    admin/sql/updates/mysql/0.0.1.sql
  3. Now just past the some code in relevant files Student.xml
     
     <?xml version="1.0" encoding="utf-8"?>
     <extension type="component" version="2.5.0" method="upgrade">
      <name>Student!>/name>
      <autthor>Amrish>/autthor>
      <copyright>Copyright Info>/copyright>
      <license>License Info>/license>
      
      
      <version>0.0.1</version>
      
      <update> 
       <schemas>
         <schemapath type="mysql">sql/updates/mysql</schemapath>
       </schemas>
      </update>
       
      <files folder="site">
       <filename>index.html</filename>
       <filename>student.php</filename>
       <filename>controller.php</filename>
       <folder>views</folder>
       <folder>models</folder>
      </files>
      
      <administration>
       
       <menu>Student!</menu>
       
       
       <files folder="admin">
        
        <filename>index.html</filename>
        <filename>student.php</filename>
        
        <folder>sql</folder>
       </files>
      </administration> 
     </extension>
     
    
    Index.html
    this file code is same for all index.html file
      <html><body bgcolor="#FFFFFF"></body></html>
     
    Site/student.php
    write any message which you want to print
    Like : Student Management System
    Admin/student.php
    write any message which you want to print
    Like : Student Management System Administrator
    admin/sql/updates/mysql/0.0.1.sql
    admin/sql/updates/mysql/0.0.1.sql is an empty file allowing to initialise schema version of the com_student component. Leave it blank
  4. you can also do the model and create view.
    For more information visit : Joomla 2.5 Component Creation

Tuesday 5 August 2014

How to Resize Image Dynamically in PHP

How to Resize Image Dynamically in PHP

There is an extremely useful PHP library called timthumb which comes very handy. It’s just a simple PHP script that you need to download and put in some folder under your website. And then simply call it with appropriate arguments.






  • Download timthumb.php and put under any folder.
  • Upload this script timthumb.php though FTP to your web hosting. Put it under a directory /script.
  • Just call timthumb.php with appropriate arguments, For example:
    <img src="/script/timthumb.php?src=/some/path/myimage.png&w=100&h=80"
        alt="resized image" />

    And that’s all!!


  • One thing worth noting here is that this library will create a folder cache in the directory where timthumb.php script resides. This folder will cache the resized image for better performance.

    You can refer following table for different parameters and its meaning.

    ParameterValuesMeaning
    srcsourceurl to imageTells TimThumb which image to resize
    wwidththe width to resize toRemove the width to scale proportionally (will then need the height)
    hheightthe height to resize toRemove the height to scale proportionally (will then need the width)
    qquality0 – 100Compression quality. The higher the number the nicer the image will look. I wouldn’t recommend going any higher than about 95 else the image will get too large
    aalignmentc, t, l, r, b, tl, tr, bl, brCrop alignment. c = center, t = top, b = bottom, r = right, l = left. The positions can be joined to create diagonal positions
    zczoom / crop0, 1, 2, 3Change the cropping and scaling settings
    ffilterstoo many to mentionLet’s you apply image filters to change the resized picture. For instance you can change brightness/ contrast or even blur the image
    ssharpenApply a sharpen filter to the image, makes scaled down images look a little crisper
    cccanvas colourhexadecimal colour value (#ffffff)Change background colour. Most used when changing the zoom and crop settings, which in turn can add borders to the image.
    ctcanvas transparencytrue (1)Use transparency and ignore background colour



    Hope this is useful for you :)

    Sunday 3 August 2014

    Redirecting www to non-www with .htaccess

    Redirecting www to non-www

    If you want to do the opposite, the code is very similar:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^my-domain\.com$ [NC]
    RewriteRule ^(.*)$ http://my-domain.com/$1 [R=301,L]
    

    Redirect non-www url to www with .htaccess

    If you want to redirect all non-www requests to your site to the www version, all you need to do is add the following code to your .htaccess file:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    

    List OF BANK PAN Numbers

    List OF BANK PAN Numbers Bank/Home Loan Providers PAN Number Allahabad Bank AACCA8464F Andhra Bank AABCA7375C Axis Bank...