Posts

Showing posts from May, 2012

most important php function

<?php Top Most important Php  function  1.   empty();   // return true false  $p = 'val' ; if(!empty( $p )){  // if $p is not empty  echo  'variable is not empty ' ; } else {  echo  'value is null' ; } 2.  unset(); use for  unse session  or  variable values  unset( $a ); 3.  isset(); if(isset( $a )){ echo  'value is set ' ; } else {   echo  'value is not set ' ; } 4. trim () use for  removes the whitespaces from the left part of the string . trim ( $a ); 5. explode  () ; convert strin to  array  $str  =  "Rajeev Dhar dwivedi" ; $array  =  explode ( " " , $str ); print_r ( $array ); outPut  : Array ( [ 0 ] =>  Rajeev  [ 1 ] =>  Dhar  [ 2 ] =>  dwivedi  ) 6. implode (); convert  array  to string  $array  = array(  'Rajeev'  , 'Dhar' , 'Dwived' ) ; echo  implode ( " " , $array ); Output  :  Rajeev Dhar Dwived 7. date () function  this  function us

export data as excel format from php mysql

<?php $file = "marksreport" . $_POST [ "txtfromdate" ]. ".xls" ; header ( 'Content-Type: text/html' );  header ( "Content-type: application/x-msexcel" );  //tried adding  charset='utf-8' into header header ( "Content-Disposition: attachment; filename=$file" ); ?> copy and paste into header in page  export to excel from project

display column values as rows in mysql query

id c1 c2 c3 1 10 20 30 2 15 50 24 SELECT 'C1' as colname, c1 as colval FROM `tablename` UNION ALL SELECT 'C2' as colname , c2 AS colval FROM `tablename` UNION ALL SELECT 'C3' as colname , c3 AS colval FROM `tablename` C1 10 c1 15 c2 20 c2 50 c3 30 c3 24 display column values as rows wise union operation in mysql 1. NUMBER OF COLUMN IS SAME  2. DATA TYPE IS SAME BUT NOT NECESSARY IN MYSQL  SELECT *   FROM `table1`   UNION   SELECT *  FROM `table2`  LIMIT 0 , 30

string replace in php

<?php $str  =  "My Name Is INPLACE " ; $str = str_replace ( "INPLACE" , "Rajeev" , $str ); echo  $str  ; // output : My Name Is Rajeev 

Widgets Development in wordpress

function.php copy and past in function.php page , you can also development more widgets area using this function <?php function  add_widgets_init () {      register_sidebar ( array(          'id'  =>  'first-sidebar' ,          'name'  =>  __ (  'First Sidebar'  ,  'buttercream'  ),          'before_widget'  =>  '<aside id="%1$s" class="widget %2$s">' ,          'after_widget'  =>  '</aside>' ,          'before_title'  =>  '<h2 class="widget-title">' ,          'after_title'  =>  '</h2>'          )     );      register_sidebar ( array(          'id'  =>  'second-sidebar' ,          'name'  =>  __ (  'Second Sidebar'  ,  'buttercream'  ),          'before_widget'  =>  '<aside id="%1$s" class="widget %2$s">'

syllabus of PHP

Syllabus of php