Profile

Sathish's Blog

What's on My Mind

Dynamic Page Allocation

dynamic_page_allocation.php:  

       Used to allocate the page size automatically according to the column size which is given by user. For example here i use 5 columns per page. If i give 8 as a column size first 5 columns will be print in firt page and remaining 3 data will be printed in the second page.

<?php

//========================================================================================+
// File name   : dynamic_page_allocation.php
// Begin       : 28-04-2014
// Last Update : 29-04-2014
//
// Description : Used to allocate the page size automatically according 
//     to the column size which is given by user. For example here i use
//     5 columns per page. If i give 8 as a column size
//     first 5 columns will be print in firt page and remaining 3 data will be 
//     printed in the second page.
//
// Author: Sathishkumar S
//
// (c) Copyright:
//               Sathishkumar S
//               http://sjksathishkumar.blogspot.com
//               sjksathishkumar@gmail.com
//========================================================================================+

// input column size given by user

$input_column = 8;
$rem_column = $input_column;
$page_count=1;

echo "input_column=$input_column<br>";

// Find the page size 

$no_of_page = ceil($input_column/5);   // Here 5 is the default page column size
echo "No of Page=$no_of_page<br>";

// Print the column if user give column size is less then 5

if($no_of_page == 1)
{
 echo "Single Pdf Page<br>";
 for ($x=1; $x<=$input_column; $x++) 
 {
  echo "Content for $page_count Page - Data no $x <tab>||";
 } 
}

// Print the column if column size is more than 5

else
{
 $x = $input_column;
 while ( $x > 5) 
  {
   echo "<br>Page No- $page_count <br>";
   for($y=1; $y<=5; $y++)
    {
     echo "Content for $page_count Page - Data no $y <tab>||";
    }
   echo "<br>-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------";
   $page_count++;
   $rem_column-=5;
   $x-=5;
  }

 echo "<br>Page No- $page_count <br>";

// Print the last page columns(Remaining columns)

 for($z=1; $z<=$rem_column; $z++)
 {
  echo "Content for $page_count Page - Data no $z <tab>||";  
 }

 echo "<br>Page Count-$page_count";
 echo "<br>Remaining Column - $rem_column";
}

?>

MySQL Data to PDF Using PHP

Using the following code you can easily convert your MySQL data to PDF using TCPDF.

TCPDF.php:


<?php
//============================================================+
// File name   : html_table_to_pdf.php
// Begin       : 28-04-2014
// Last Update : 29-04-2014
//
// Description : Used to print pdf from html table
//
// Author: Sathishkumar S
//
// (c) Copyright:
//               Sathishkumar S
//               http://sjksathishkumar.blogspot.com
//               sjksathishkumar@gmail.com
//============================================================+

// Include the main TCPDF library (search for installation path).
require_once('tcpdf_include.php');

// mysql connection
$con = mysql_connect("localhost","root");
  if(!$con)
      {
      die(mysql_error());
      }
   
// get data from users table
mysql_select_db("sathish");
$result = mysql_query("SELECT * FROM emp");

// create new PDF document
$pdf = new TCPDF("L", PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information
/*$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 006');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
*/
// set default header data
//$pdf->SetHeaderData('', '', 'Bass Techs - Employee Data', 'www.basstechs.com');

// set header and footer fonts
//$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
//$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// set default monospaced font
//$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

// set margins
//$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
//$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
//$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, "8");

// set image scale factor
//$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}

// ---------------------------------------------------------

// set font
$pdf->SetFont('dejavusans', '', 8);

// add a page
$pdf->AddPage();

// create some HTML content

$html .= '<table border="1"  cellpadding="2">
<thead>
<tr bgcolor="#d2d2cd">
<th width="50" align="center">EMP_ID</th>
<th width="100" align="center">EMP_NAME</th>
<th width="80" align="center">BANK_NAME</th>
<th width="80" align="center">BRANCH</th>
<th width="70" align="center">DATE_JOIN</th>
<th width="145" align="center">DESIGNATION</th>
<th width="60" align="center">DEPARTMENT</th>
<th width="100" align="center">ASM</th>
<th width="40" align="center">PF_NO</th>
<th width="70" align="center">ESI_NO</th>
</tr>
</thead>';

// print the mysql content to table row

while($row = mysql_fetch_array($result))
  {
    $emp_id = $row['emp_id'];
    $emp_name = $row['emp_name'];
    $branch = $row['branch'];
    $dt_of_join = $row['dt_of_join'];
    $bank_name = $row['bank_name'];
    $bank_acc_no = $row['bank_acc_no'];
$designation = $row['designation'];
$emp_dep = $row['emp_dep'];
$asm = $row['asm'];
$pf_no = $row['pf_no'];
$esi_no = $row['esi_no'];
$basic = $row['basic'];
$utilty_allow = $row['utilty_allow'];
$communication = $row['communication'];
$mt_allow = $row['mt_allow'];
$spl_allow = $row['spl_allow'];
$house_rnt_allow = $row['house_rnt_allow'];
$child_hstl_allow = $row['child_hstl_allow'];
$project_allow = $row['project_allow'];
$email = $row['email'];
$mobile = $row['mobile'];
$html .='<tr>
<td width="50">'.$emp_id.'</td>
<td width="100">'.$emp_name.'</td>
<td width="80">'.$bank_name.'</td>
<td width="80">'.$branch.'</td>
<td width="70">'.$dt_of_join.'</td>
<td width="145">'.$designation.'</td>
<td width="60">'.$emp_dep.'</td>
<td width="100">'.$asm.'</td>
<td width="40">'.$pf_no.'</td>
<td width="70">'.$esi_no.'</td>
</tr>';
 }

$html .='</table>';

// output the HTML content
$pdf->writeHTML($html, true, false, true, false, '');

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

// reset pointer to the last page
$pdf->lastPage();

// End of First Table
// ---------------------------------------------------------

//=================================================================
//==========Remaing coloums printing===============================

// set font
$pdf->SetFont('dejavusans', '', 8);

// add a page
$pdf->AddPage();

// create some HTML content
$html2 .= '<table border="1"  cellpadding="2">
<thead>
<tr bgcolor="#d2d2cd">
<th width="50" align="center">EMP_ID</th>
<th width="50" align="center">BASIC</th>
<th width="80" align="center">UTILITY_ALLOW</th>
<th width="80" align="center">COMMUNICATION</th>
<th width="50" align="center">MT_ALLOW</th>
<th width="60" align="center">SPL_ALLOW</th>
<th width="100" align="center">HOUSE_RENT_ALLOW</th>
<th width="100" align="center">CHILD_HSTL_ALLOW</th>
<th width="80" align="center">PROJECT_ALLOW</th>
<th width="80" align="center">MOBILE</th>
</tr>
</thead>';

//Reinitialise the $result

$result = mysql_query("SELECT * FROM emp");

// print the mysql content to table row

while($row = mysql_fetch_array($result))
  {
    $emp_id = $row['emp_id'];
    $emp_name = $row['emp_name'];
    $branch = $row['branch'];
    $dt_of_join = $row['dt_of_join'];
    $bank_name = $row['bank_name'];
    $bank_acc_no = $row['bank_acc_no'];
$designation = $row['designation'];
$emp_dep = $row['emp_dep'];
$asm = $row['asm'];
$pf_no = $row['pf_no'];
$esi_no = $row['esi_no'];
$basic = $row['basic'];
$utilty_allow = $row['utilty_allow'];
$communication = $row['communication'];
$mt_allow = $row['mt_allow'];
$spl_allow = $row['spl_allow'];
$house_rnt_allow = $row['house_rnt_allow'];
$child_hstl_allow = $row['child_hstl_allow'];
$project_allow = $row['project_allow'];
$email = $row['email'];
$mobile = $row['mobile'];
$html2 .='<tr>
<td width="50">'.$emp_id.'</td>
<td width="50">'.$basic.'</td>
<td width="80">'.$utilty_allow.'</td>
<td width="80">'.$communication.'</td>
<td width="50">'.$mt_allow.'</td>
<td width="60">'.$spl_allow.'</td>
<td width="100">'.$house_rnt_allow.'</td>
<td width="100">'.$child_hstl_allow.'</td>
<td width="80">'.$project_allow.'</td>
<td width="80">'.$mobile.'</td>
</tr>';
 }

$html2 .='</table>';

// output the HTML content

$pdf->writeHTML($html2, true, false, true, false, '');

// Print some HTML Cells

//$html = '<span color="red">red</span> <span color="green">green</span> <span color="blue">blue</span><br /><span color="red">red</span> <span color="green">green</span> <span color="blue">blue</span>';

//$pdf->SetFillColor(255,255,0);
//$pdf->writeHTMLCell(0, 0, '', '', $html, 'LRTB', 1, 0, true, 'L', true);
//$pdf->writeHTMLCell(0, 0, '', '', $html, 'LRTB', 1, 1, true, 'C', true);
//$pdf->writeHTMLCell(0, 0, '', '', $html, 'LRTB', 1, 0, true, 'R', true);

// reset pointer to the last page
$pdf->lastPage();

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Print a table
// ---------------------------------------------------------

// Clean the buffer

ob_end_clean();

//Close and output PDF document
$pdf->Output('report.pdf', 'I');

//============================================================+
// END OF FILE
//============================================================+

SEO Keyword Research


            Before you can start optimizing your site for the search engines, you must first know which terms you want to target. A good start would be to choose 3 or 4 keywords you would like your website to rank well for. With these keywords in your mind you can then set a goal to rank in the top 10 results on Google for each of them (we refer to Google because if you can rank well there, you'll rank well on the other search engines). These keywords can be either broad or specific, but you'll want to study our list of pros and cons of each before choosing.

Broad Keywords:

         A broad keyword is one that many people search for, because they may only have a vague idea of what they're looking for. Broad keywords tend to be very short and aren't very specific (e.g. "shoes" or "sports"). These keywords are difficult to rank #1 for because so many other websites might have an article or two that mention shoes. However, if you can rank well for a broad keyword, you will be receiving a great deal of traffic.

Summary: Hard to rank for, but worth it in the long run. We recommend that beginners only choose a broad keyword if their industries are not very competitive.

Specific Keywords:

       A specific keyword is something that contains many adjectives or words that make the search very targeted. The people doing these types of searches know exactly what they want (e.g. "used black high heel shoes"). These keywords are much less competitive and are easier to rank for on search engines. The downside is that they receive a great deal less volume of searches per month. In terms of traffic, you will need to have several #1 rankings for specific keywords to equal one #1 ranking broad keyword.

Summary: Easier to rank for and it's highly targeted traffic. The only downside is that the number of visitors you will receive is relatively low.

Unique or Branded Keywords:

       These are the words that are specific to only your company. They are one of the most easiest ways to get traffic. However, some companies will release a new product, with a unique name, and then forget to optimize for that keyword on their website. Their SEO savvy competitors can then pick up the slack and take over the top rankings for these terms. If you have a popular brand or product, make sure that you have optimized for these freebie keywords.

Keyword Research Tools:

      Keyword research tools are 2 parts voodoo magic and 1 part hard statistic. This is partly due to Google not releasing actual numbers and partly due to overeager SEO Tool developers trying to sell their products. Because there is such a sizable uncertainty in all keyword research tools, it is best to use as many different sources as you can,. Even with multiple sources, you should only take the information you gather as a recommendation, rather than a fact.

     Yahoo has been releasing their keyword search information for years, and many tools are based off of this specific data. We've collected a wide variety of helpful tools that will give you a general idea of which keywords you should target when making and optimizing your websites.

Picking a Short List:

        To put the optimizing tactics that we teach to good use, we recommend that you try to target no more than 2 or 3 keyword phrases per page. A common mistake by many SEO beginners is to stuff 500 different keywords on one page and wait for the #1 rankings to roll in. That might have worked 10 years ago, but the algorithms that search engines use these days are much more sophisticated and are not tricked by this. That's why it's best to start small, and be concise with the keywords that you choose. New sites in particular will find it nearly impossible to rank well for many keyword phrases upon first starting out.

SEO


     Search engine optimization (SEO) is the process of improving the visibility of a website or a web page in a search engine's "natural" or un-paid ("organic" or "algorithmic") search results. In general, the earlier (or higher ranked on the search results page), and more frequently a site appears in the search results list, the more visitors it will receive from the search engine's users. SEO may target different kinds of search, including image search, local search, video search, academic search, news search and industry-specific vertical search engines.

     As an Internet marketing strategy, SEO considers how search engines work, what people search for, the actual search terms or keywords typed into search engines and which search engines are preferred by their targeted audience. Optimizing a website may involve editing its content and HTML and associated coding to both increase its relevance to specific keywords and to remove barriers to the indexing activities of search engines. Promoting a site to increase the number of backlinks, or inbound links, is another SEO tactic.
The plural of the abbreviation SEO can refer to "search engine optimizers," those who provide SEO service.

Methods:

Getting indexed:

        The leading search engines, such as Google, Bing and Yahoo!, use crawlers to find pages for their algorithmic search results. Pages that are linked from other search engine indexed pages do not need to be submitted because they are found automatically. Some search engines, notably Yahoo!, operate a paid submission service that guarantee crawling for either a set fee or cost per click. Such programs usually guarantee inclusion in the database, but do not guarantee specific ranking within the search results. Two major directories, the Yahoo Directory and the Open Directory Project both require manual submission and human editorial review. Google offers Google Webmaster Tools, for which an XML Sitemap feed can be created and submitted for free to ensure that all pages are found, especially pages that are not discoverable by automatically following links.

     Search engine crawlers may look at a number of different factors when crawling a site. Not every page is indexed by the search engines. Distance of pages from the root directory of a site may also be a factor in whether or not pages get crawled.

Preventing crawling:
      To avoid undesirable content in the search indexes, webmasters can instruct spiders not to crawl certain files or directories through the standard robots.txt file in the root directory of the domain. Additionally, a page can be explicitly excluded from a search engine's database by using a meta tag specific to robots. When a search engine visits a site, the robots.txt located in the root directory is the first file crawled. The robots.txt file is then parsed, and will instruct the robot as to which pages are not to be crawled. As a search engine crawler may keep a cached copy of this file, it may on occasion crawl pages a webmaster does not wish crawled. Pages typically prevented from being crawled include login specific pages such as shopping carts and user-specific content such as search results from internal searches. In March 2007, Google warned webmasters that they should prevent indexing of internal search results because those pages are considered search spam.

Increasing prominence:
       A variety of methods can increase the prominence of a webpage within the search results. Cross linking between pages of the same website to provide more links to most important pages may improve its visibility. Writing content that includes frequently searched keyword phrase, so as to be relevant to a wide variety of search queries will tend to increase traffic. Updating content so as to keep search engines crawling back frequently can give additional weight to a site. Adding relevant keywords to a web page's meta data, including the title tag and meta description, will tend to improve the relevancy of a site's search listings, thus increasing traffic. URL normalization of web pages accessible via multiple urls, using the canonical link element or via 301 redirects can help make sure links to different versions of the url all count towards the page's link popularity score.





QR CODE

        QR Code (abbreviated from Quick Response Code) is the trademark for a type of matrix barcode (or two-dimensional code) first designed for the automotive industry. More recently, the system has become popular outside the industry due to its fast readability and large storage capacity compared to standard UPC barcodes. The code consists of black modules (square dots) arranged in a square pattern on a white background. The information encoded can be made up of four standardized kinds ("modes") of data (numeric, alphanumeric, byte/binary, Kanji), or through supported extensions, virtually any kind of data.

Invention:
        The QR Code was invented in Japan by the Toyota subsidiary Denso Wave in 1994 to track vehicles during the manufacturing process, and was originally designed to allow components to be scanned at high speed .It has since become one of the most popular types of two-dimensional barcodes.

       Unlike the older one-dimensional barcode that was designed to be mechanically scanned by a narrow beam of light, the QR code is detected as a 2-dimensional digital image by a semiconductor image sensor and is then digitally analyzed by a programmed processor. The processor locates the three distinctive squares at the corners of the image, and uses a smaller square near the fourth corner to normalize the image for size, orientation, and angle of viewing. The small dots are then converted to binary numbers and validity checked with an error-correcting code.

Standards:
There are several standards in documents covering the physical encoding of QR Codes:

  • October 1997 – AIM (Association for Automatic Identification and Mobility) International
  • January 1999 – JIS X 0510
  • June 2000 – ISO/IEC 18004:2000 Information technology – Automatic identification and data capture techniques – Bar code symbology – QR code
  • 1 September 2006 – ISO/IEC 18004:2006 Information technology – Automatic identification and data capture techniques – QR Code 2005 bar code symbology specification
Uses:
       Formerly only for industrial uses, they have in recent years become common in consumer advertising and packaging, because the popularity of smartphones "has put a barcode reader in everyone's pocket" for the first time. As a result, the QR Code has become a focus of advertising strategy, since it provides quick and effortless access to the brand's website. Beyond mere convenience to the consumer, the importance of this capability is that it increases the conversion rate (that is, increase the chance that contact with the advertisement will convert to a sale), by coaxing qualified prospects further down the conversion funnel without any delay or effort, bringing the viewer to the advertiser's site immediately, where a longer and more targeted sales pitch may continue. Although initially used to track parts in vehicle manufacturing, QR Codes are now (as of 2012) used over a much wider range of applications, including commercial tracking, entertainment and transport ticketing, product/loyalty marketing (examples: mobile couponing where a company's discounted and percent discount can be captured using a QR Code decoder which is a mobile app, or storing a company's information such as address and related information alongside its alpha-numeric text data as can be seen in Yellow Pages directory), and in-store product labeling. It can also be used in storing personal information for use by government. An example of this is Philippines National Bureau of Investigation (NBI) where NBI clearances now come with a QR Code. Many of these applications target mobile-phone users (via mobile tagging). Users may receive text, add a vCard contact to their device, open a Uniform Resource Identifier (URI), or compose an e-mail or text message after scanning QR Codes. They can generate and print their own QR Codes for others to scan and use by visiting one of several pay or free QR Code-generating sites or apps. Google has a popular API to generate QR Codes, and apps for scanning QR Codes can be found on nearly all smartphone devices.

QR Codes storing addresses and Uniform Resource Locators (URLs) may appear in magazines, on signs, on buses, on business cards, or on almost any object about which users might need information. Users with a camera phone equipped with the correct reader application can scan the image of the QR Code to display text, contact information, connect to a wireless network, or open a web page in the telephone's browser. This act of linking from physical world objects is termed hardlinking or object hyperlinking. QR Codes may also be linked to a location to track where a code has been scanned. Either the application that scans the QR Code retrieves the geo information by using GPS and cell tower triangulation (aGPS) or the URL encoded in the QR Code itself is associated with a location.

QR codes have been used and printed on Chinese train tickets since late 2009.

In June 2011, the Royal Dutch Mint (Koninklijke Nederlandse Munt) issued the world's first official coin with a QR Code to celebrate the centennial of its current building and premises. The coin was able to be scanned by a smartphone and link to a special website with contents about the historical event and design of the coin. This was the first time of a QR code used on currency.

Use in mobile operating systems:
      QR Codes can be used in Google's mobile Android operating system using Google Goggles or 3rd party barcode scanners. QR Codes can be used in iOS devices [iPhone/iPod/iPad] via 3rd party barcode scanners. The browser supports URI redirection, which allows QR Codes to send metadata to existing applications on the device. Nokia's Symbian operating system features a barcode scanner which can read QR Codes, while mbarcode is a QR Code reader for the Maemo operating system. In the Apple iOS, a QR Code reader is not natively included, but more than fifty paid and free apps are available with both scanning capabilities and hard-linking to URI. Google Goggles is also available for iOS. With BlackBerry devices, the App World application can natively scan QR Codes and load any recognized Web URLs on the device's Web browser. Windows Phone 7.5 is able to scan QR Codes through the Bing search app. They can also be used on the Nintendo 3DS.

There are a number of websites that provide QR Code decoding. The lack of functioning tools for decoding from image files or webcams within either the MacOS or Linux PC-based operating systems make this standard unpalatable as a data-backup method for storing private data, such as passwords or encryption keys.

Uses in retail:
       Recently there has been a move away from traditional magnetic card, stamp or punchcard based schemes to QR code based loyalty programs. One prominent example is the US-based Punchd, which became part of Google in 2011. Others, like MazeCard, have offered similar applications of QR codes in other continents.

Encryption:
      Encrypted QR Codes, which are not very common, have a few implementations. An Android app, for example, manages encryption and decryption of QR codes using the DES algorithm (56 bits). Japanese immigration use encrypted QR Codes when placing visas in passports.

Encoding:
     The format information records two things: the error correction level and the mask pattern used for the symbol. Masking is used to break up patterns in the data area that might confuse a scanner, such as large blank areas or misleading features that look like the locator marks. The mask patterns are defined on a 6×6 grid that is repeated as necessary to cover the whole symbol. Modules corresponding to the dark areas of the mask are inverted. The format information is protected from errors with a BCH code, and two complete copies are included in each QR symbol.
      The message data is placed from right to left in a zigzag pattern, as shown below. In larger symbols, this is complicated by the presence of the alignment patterns and the use of multiple interleaved error-correction blocks.