Tuesday, 24 July 2012

Delete and Update cascading constraint in existing table


ALTER TABLE `emp_details` ADD
   CONSTRAINT `foreign_key_const`
   FOREIGN KEY (`emp_id`) REFERENCES `employee` (`emp_id`)
   ON DELETE CASCADE ON UPDATE CASCADE

Monday, 16 July 2012

Removing Extra White Space in Google Custom Search



Hi All,

     I have done a lot of R&D to find the solution of Google Custom Search White Space Issue.


1. <form action="http://www.test.newhomestar.com/search.php" id="cse-search-box">
            <input type="hidden" name="cx" value="xxxxx90948434568903:14dqcrlsktw" />
            <input type="hidden" name="cof" value="FORID:11" />
            <input type="hidden" name="ie" value="UTF-8" />
            <input type="text" name="q" size="31" class="inp-hdr"/>
            <input type="submit" name="sa" value="" class="go-button"  />
          </form>
          <script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&lang=en"></script>

//Create a div and do inline styling and put height:1140px or as per your requirement. 


 2. <div id="cse-search-results" style="overflow: hidden;text-align: left; height:1140px"></div>
         <script type="text/javascript">
         var googleSearchIframeName = "cse-search-results";
         var googleSearchFormName = "cse-search-box";
         var googleSearchFrameWidth = 590; <!----you can change width
         var googleSearchDomain = "www.google.com";
         var googleSearchPath = "/cse";
         var googleSearchResizeIframe = true;
         var a=encodeURIComponent;
       </script>
        <script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script>
   </div>

Check it out the working solution @ click here

Friday, 6 July 2012

Attach multiple files in the mail using php


 The following function will send a mail with attachment.. Just need to copy-paste the function and made basic changes in it.

 /**
 *  parameter :  Array $attach Contains the number of file and their names
 *  parameter : String $message   Message to the user like PFA
 *  parameter : $mailto receiver@abc.com
 *  parameter : $subject This is attached mail.
**/             

 function   mail_with_attachment($attach,$message, $mailto, $subject )
{
       
                 $files = array();
                $unique_id = md5(time());
                foreach($attach as $a){
                  
               $attachment = './path/to/file/folder/'.$a['filename'];                  
               $aFile = fopen($attachment,"rb");
               $data = fread($aFile,filesize($attachment));
               fclose($aFile);
               $data = chunk_split(base64_encode($data));
               $headers .= "MIME-Version: 1.0\r\n";
               $headers .= "Content-Type: multipart/mixed; boundary=\"".$unique_id."\"\r\n\r\n";
               $headers .= "--".$unique_id."\r\n";
               $headers .= "Content-type:text/html; charset=iso-8859-1\r\n";
              $headers .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
              $headers .= $message."\r\n\r\n";
              $headers .= "--".$unique_id."\r\n";
              $headers .= "Content-Type: application/octet-stream; name=\"".$a['filename']."\"\r\n";
              $headers .= "Content-Transfer-Encoding: base64\r\n";
              $headers .= "Content-Disposition: attachment; filename=\"".$a['filename']."\"\r\n\r\n";
              $headers .= $data."\r\n\r\n";
              $headers .= "--".$unique_id."--";
   
               
              //MAIL TO USER
             $mailSend = mail ($mailto , $subject ," " , $headers); 
         if($mailSend)
        {
            echo "Mail Send Successfully .. :-)";
         }
        else
        {
             echo "Sorry, there is some error.. Comment to me ... :-( ";
        }


}//End Function