Wednesday, April 29, 2015

MySQL query finding values in a comma separated string

I have a field COLORS (varchar(50)) in a my table SHIRTS that contains a comma delimited string such as 1,2,5,12,15,. Each number representing the available colors.

When running the query select * from shirts where colors like '%1%' to get all the red shirts (color=1), I also get the shirts who's color is grey (=12) and orange (=15).

How should I rewrite the query so that is selects ONLY the color 1 and not all colors containing the number 1?



Answer : select * from shirts where FIND_IN_SET(1,colors)

Wednesday, February 18, 2015

How to find a input hidden element in jquery ajax success html response?

success: function(data){
        var $response = $(data);
        var errorMessage = $response.find('#errorMessage').val();
        alert(errorMessage);

}

Get values of all textboxes with same name attributes in jquery

I need to get values of all textboxes with same name attributes using jquery.

<input type="text" id="text1" name="tax[]">
<input type="text" id="text2" name="tax[]">
<input type="text" id="text3" name="tax[]">




Answer :

$('input[name="tax[]"]').each(function() {
    alert($(this).val());
});

Thursday, February 23, 2012

How to install android sdk on windows,mac and linux

Here’s a quick start installation guide to get you up and running with the Google Android Software Development Kit (SDK). This guide will describe how to install the Android SDK and set up your chosen development environments. If you’ haven’t already done so you can download the Android SDK from the link below, then we can get started.

First you’ll need to download the Android SDK source files:
( http://code.google.com/android/download.html )

System Requirements

In order to first use the Android SDK code and tools for development you will of course need a suitable environment develop from.

Currently the following operating systems are supported:

  • Windows XP or Vista
  • Mac OS X 10.4.8 or later (x86 only)
  • Linux (tested on Linux Ubuntu Dapper Drake)

You will also need to install a suitable development environment such as:

Installing The Android SDK

First you will need to download the Android SDK pack .zip archive, once downloaded find a suitable installation location on your machine and extract the zipped files.

Please note: This installation location will be referred to as $SDK_ROOT from now on through this tutorial

Alternatively you can add /tools to your root path which will prevent the need to specify the full path to the tools directory along with enabling you to run Android Debug Bridge (adb) along with other command line tools.

To add /tools:

Linux

  1. Edit the ~/.bash_profile or ~/.bashrc files looking for a line that sets the PATH variable.
  2. Add the full path location to your $SDK_ROOT/tools location for the PATH variable.
  3. If no PATH line exists you can add the line by typing the following:
  4. export PATH=${PATH}:

Mac OS X

  1. In the home directory locate the .bash_profile and locating the PATH variable add the location to your $SDK_ROOT/tools folder.

Windows XP / Vista

  1. Right click on the My Computer icon and select the properties tab.
  2. Select the Advanced tab and click the Environment Variables button.
  3. In the new dialog box dowble-click on Path (located under System Variables) and type in the full path location to the tools directory.

The Android SDK also requires a suitable development environment to work in, here’s the installation guides for each of the supported environments.

Android Eclipse Plugin (ADT)

If you choose to use the Eclipse IDE as your Android development environment you will have the opportunity to install and run a plug-in called Android Development Tools. ADT comes with a variety of powerful tools and extensions that will make creating, running and debugging your Android applications much easier and faster.

In order to download and install ADT you will first need to configure an Eclipse remote update, this can achieved via the following steps:

  1. Start Eclipse, then select Help > Software Updates > Find and Install….
  2. In the dialog that appears, select Search for new features to install and press Next.
  3. Press New Remote Site.
  4. In the resulting dialog box, enter a name for the remote site (e.g. Android Plugin) and enter this as its URL: https://dl-ssl.google.com/android/eclipse/.
  5. Press OK.
  6. You should now see the new site added to the search list (and checked).
  7. Press Finish.
  8. In the subsequent Search Results dialog box, select the checkbox for Android Plugin > Eclipse Integration > Android Development Tools and press Next.
  9. Read the license agreement and then select Accept terms of the license agreement, if appropriate.
  10. Press Next.
  11. Press Finish.
  12. The ADT plugin is not signed; you can accept the installation anyway by pressing Install All.
  13. Restart Eclipse.
  14. After restart, update your Eclipse preferences to point to the SDK root directory ($SDK_ROOT):
    Select Window > Preferences… to open the Preferences panel. (Mac OS X: Eclipse > Preferences)
    Select Android from the left panel.
    For the SDK Location in the main panel, press Browse... and find the SDK root directory.
  15. Press Apply, then OK

Updating the ADT Plugin

To update the ADT plugin to the latest version, follow these steps:

  1. Select Help > Software Updates > Find and Install….
  2. Select Search for updates of the currently installed features and press Finish.
  3. If any update for ADT is available, select and install.

Alternatively:

  1. Select Help > Software Updates > Manage Configuration.
  2. Navigate down the tree and select Android Development Tools
  3. Select Scan for Updates under Available Tasks.

How-To Use Eclipse To Develop Android Applications

In order to begin development on your Android applications you will first need to create a new Android project and then configure a launch configuration. Once completed you will have the capability to write, run and debug your Android creations.

The following sections below will provide you with the necessary instructions to get you up and running with Android provided you have installed the ADT plugin (as previously mentioned) in your Eclipse environment.

Creating A New Android Project

The Android Development Tools plugins kindly provides a Wizard for setting up new Projects which will allow us to create new Eclipse projects relatively quickly for either new or existing code.

Select File > New > Project

  1. Select Android > Android Project, and press Next
  2. Select the contents for the project:
  • Select Create new project in workspace to start a project for new code. Enter the project name, the base package name, the name of a single Activity class to create as a stub .java file, and a name to use for your application.
  • Select Create project from existing source to start a project from existing code. Use this option if you want to build and run any of the sample applications included with the SDK. The sample applications are located in the samples/ directory in the SDK. Browse to the directory containing the existing source code and click OK. If the directory contains a valid Android manifest file, the ADT plugin fills in the package, activity, and application names for you.

Press Finish.

Once completed the ADT plugin will go ahead and create the following files and folders as appropriate for the type of project selected:

  • src/ A folder that includes your stub .java Activity file.
  • res/ A folder for your resources.
  • AndroidManifest.xml The manifest for your project.

Creating A Launch Configuration For Eclipse

In order to be able to run and debug your own Eclipse applications you must first create a launch configuration. Simply, a launch config is used to specify which project to launch, which activity to start and the specific emulation options to use.

To create a launch configuration for the application, please see the following steps:
1. Select Run > Open Run Dialog… or Run > Open Debug Dialog… as appropriate.
2. In the project type list on the left, right-click Android Application and select New.
3. Enter a name for your configuration.
4. On the Android tab, browse for the project and Activity to start.
5. On the Emulator tab, set the desired screen and network properties, as well as any other emulator startup options.
6. You can set additional options on the Common tab as desired.
7. Press Apply to save the launch configuration, or press Run or Debug (as appropriate).

Running and Debugging an Eclipse Application

Once both steps 1 and 2 have been completed and your project and launch configs are up and running you will now be able to run or debug your application.

From the Eclipse main menu, select Run > Run or Run > Debug as appropriate. This command will run or debug the most recently selected application.

To set or change the active launch configuration, use the Run configuration manager, which you can access through Run > Open Run Dialog… or Run > Open Debug Dialog….

Running or debugging the application will trigger the following actions:

  • Starts the emulator, if it is not already running.
  • Compile the project, if there have been changes since the last build, and installs the application on the emulator.
  • Run starts the application.
  • Debug starts the application in “Wait for debugger” mode, then opens the Debug perspective and attaches the Eclipse Java debugger to the application.

Developing Android Applications with Other IDEs and Tools

Although it is recommended you use Eclipse with the Android plugin to develop your applications, the SDK also provides tools which will enable you to develop with other IDE’s including intelliJ (alternatively you could just use Eclipse without the plugin).

Creating an Android Project

Bundled with the Android SDK is a program called activityCreatory. activityCreator will generate a number of ‘stub’ files for your chosen project alongside a build file. This can be used to either create an Android project for new code or from existing code.

For Linux and Mac users the Android SDK provides a Python script called activityCreator.py, with Windows users receiving a btach script called activityCreator.bat. The program is used in the same way regardless of operating system.

In order to run activityCreator and create an Android project, follow these steps:

  1. In the command line, change to the tools/ directory of the SDK and create a new directory for your project files. If you are creating a project from existing code, change to the root folder of your application instead.
  2. Run activityCreator. In the command, you must specify a fully-qualified class name as an argument. If you are creating a project for new code, the class represents the name of a stub class that the script will create. If you are creating a project from existing code, you must specify the name of one Activity class in the package. Command options for the script include:

–out which sets the output directory. By default, the output directory is the current directory. If you created a new directory for your project files, use this option to point to it.

–ide intellij, which generates IntelliJ IDEA project files in the newly created project
Here’s an example:

/android_linux_sdk/tools$ ./activityCreator.py –out myproject your.package.name.ActivityName
package: your.package.name
out_dir: myproject
activity_name: ActivityName
~/android_linux_sdk/tools$

The activityCreator script generates the following files and directories (but will not overwrite existing ones):

  • AndroidManifest.xml The application manifest file, synced to the specified Activity class for the project.
  • build.xml An Ant file that you can use to build/package the application.
  • src/your/package/name/ActivityName.java The Activity class you specified on input.
  • your_activity.iml, your_activity.ipr, your_activity.iws [only with the -ide intelliJ flag] intelliJ project files.
  • res/ A directory to hold resources.
  • src/ The source directory.
  • bin/ The output directory for the build script.

Once complete you will now be able to move your folder wherever you choose for development but you’ll need to bear in mind then you will need to use the adb program in the tools folder in order to send the files to the emulator.

How-To Build An Android Application

Here’s how to use the Ant build.xml file generated by activityCreator to build your application.

  1. If you don’t have it, you can obtain Ant from the Apache Ant home page. Install it and make sure it is on your executable path.
  2. Before calling Ant, you need to declare the JAVA_HOME environment variable to specify the path to where the JDK is installed.Note: When installing JDK on Windows, the default is to install in the “Program Files” directory. This location will cause ant to fail, because of the space. To fix the problem, you can specify the JAVA_HOME variable like this: set JAVA_HOME=c:\Prora~1\Java\. The easiest solution, however, is to install JDK in a non-space directory, for example: c:\java\jdk1.6.0_02.
  3. If you have not done so already, follow the instructions for Creating a New Project above to set up the project.
  4. You can now run the Ant build file by simply typing ant in the same folder as the build.xml file for your project. Each time you change a source file or resource, you should run ant again and it will package up the latest version of the application for you to deploy.

How-To Run An Android Application

In order to run a compiled application you will first need to upload the .apk file to the /data/app/ directory in the emulator using the adb tool:

  1. Start the emulator (run $SDK_HOME/tools/emulator from the command line)
  2. On the emulator, navigate to the home screen (it is best not to have that application running when you reinstall it on the emulator; press the Home key to navigate away from that application).
  3. Run adb install myproject/bin/.apk to upload the executable. So, for example, to install the Lunar Lander sample, navigate in the command line to $SDK_ROOT/sample/LunarLander and type ../../tools/adb install bin/LunarLander.apk
  4. In the emulator, open the list of available applications, and scroll down to select and start your application.

Please Note: When installing an activity for the first time you may need to restart the emulator engine in order for the activity to show up in the application launcher or before any other application can call. This is usually down to the fact that the package manager normally only examines manifests completely on emulator start-up.

How-To Attach a Debugger to Your Application

The following section details how to display debug information directly onto the screen (for example CPU usage). It also shows you how to hook up your IDE to debug running applications on the emulator.

The Eclipse plugin automatically attaches a debugger but you can configure other IDE’s to wait on a debugging port by doing the following:

Start the Dalvik Debug Monitor Server (DDMS) tool , which acts as a port forwarding service between your IDE and the emulator.

  1. Set optional debugging configurations on your emulator, such as blocking application startup for an activity until a debugger is attached. Note that many of these debugging options can be used without DDMS, such as displaying CPU usage or screen refresh rate on the emulator.
  2. Configure your IDE to attach to port 8700 for debugging. We’ve included information higher up on how to set up Eclipse to debug your project.

How-To Configure Your IDE To Attach To The Debugging Port

DDMS will automatically assign a specific debugging port for every virtual machine that it detects on the emulator. You must either attach your IDE to that port, or use a default port 8700 to connect to whatever application is currently selected on the list of discovered virtual machines.

Ideally your IDE will attach to the application running on the emulator, showing its threads and allowing you to suspend them, inspect them, or set breakpoints. If you choose to “Wait for debugger” in the Development settings panel, this will cause the application to run when Eclipse connects therefore you will need to set any breakpoints you want before connecting. If you change the application being debugged or the “Wait for debugger” then the system will kill the selected currently running application.

This can be handy if your application is in a bad state, you can simply go to the settings and toggle the checkbox to kill it.

Debugging Android

Google Android has a fairly extensive set of tools to help you debug your programs:

  • DDMS – A graphical program that supports port forwarding (so you can set up breakpoints in your code in your IDE), screen captures on the emulator, thread and stack information, and many other features. You can also run logcat to retrieve your Log messages. See the linked topic for more information.
  • logcat – Dumps a log of system messages. The messages include a stack trace when the emulator throws an error, as well as Log messages. To run logcat, see the linked topic. …
    I/MemoryDealer( 763): MemoryDealer (this=0x54bda0): Creating 2621440 bytes heap at 0x438db000
    I/Logger( 1858): getView() requesting item number 0
    I/Logger( 1858): getView() requesting item number 1
    I/Logger( 1858): getView() requesting item number 2
    D/ActivityManager( 763): Stopping: HistoryRecord{409dbb20 com.google.android.home.AllApps}
    …
  • Android Log- A logging class to print out messages to a log file on the emulator. You can read messages in real time if you run logcat on DDMS (covered next). Add a few logging method calls to your code.
  • To use the Log class, you just call Log.v() (verbose), Log.d() (debug), Log.i() (information), Log.w() (warning) or Log.e (error) depending on the importance you wish to assign the log message.
    Log.i(“MyActivity”, “MyClass.getView() — Requesting item number ” + position) You can use logcat to read these messages

  • Traceview – Android can save a log of method calls and times to a logging file that you can view in a graphical reader called Traceview. See the linked topic for more information.
  • Eclipse plugin – The Eclipse Android plugin incorporates a number of these tools (ADB, DDMS, logcat output, and other functionality). See the linked topic for more information.
  • Debug and Test Device Settings – Android exposes several settings that expose useful information such as CPU usage and frame rate.

Debug and Test Settings on the Device

Android enables you to set a number of options that will make it far easier to test and debug your applications.

To get to the development settings page on the emulator simply go to Dev Tools > Development Settings. This will in turn open up the development settings page with the following options (among others):

  • Debug app Selects the application that will be debugged. You do not need to set this to attach a debugger, but setting this value has two effects:

It will prevent Android from throwing an error if you pause on a breakpoint for a long time while debugging.

It will enable you to select the Wait for Debugger option to pause application startup until your debugger attaches (described next).

  • Wait for debugger Blocks the selected application from loading until a debugger attaches. This way you can set a breakpoint in onCreate(), which is important to debug the startup process of an Activity. When you change this option, any currently running instances of the selected application will be killed. In order to check this box, you must have selected a debug application as described in the previous option. You can do the same thing by adding waitForDebugger() to your code.
  • Immediately destroy activities Tells the system to destroy an activity as soon as it is stopped (as if Android had to reclaim memory). This is very useful for testing the onFreeze(Bundle) / onCreate(android.os.Bundle) code path, which would otherwise be difficult to force. Choosing this option will probably reveal a number of problems in your application due to not saving state.
  • Show screen updates Flashes a momentary pink rectangle on any screen sections that are being redrawn. This is very useful for discovering unnecessary screen drawing.
  • Show CPU usage Displays CPU meters at the top of the screen, showing how much the CPU is being used. The top red bar shows overall CPU usage, and the green bar underneath it shows the CPU time spent in compositing the screen. Note: You cannot turn this feature off once it is on, without restarting the emulator.
  • Show screen FPS Displays the current frame rate. Mostly useful for games to see the overall frame rate they are achieving. Note: You cannot turn this feature off once it is on without restarting the emulator.
  • Show background Displays a background pattern when no activity screens are visible. This typically does not happen, but can happen during debugging.

Thursday, February 16, 2012

Finding the Nth Highest Salary from table

This is the most common question asked in every interview for the database. As I am more familiar with mysql , Its so simple with the following query

SELECT * FROM employee ORDER BY salary DESC LIMIT 2,1

This query will bring the second highest salary from the table employee.

But Query should work with every database so here is the correct query and its details explaination which will bring specified highest salary from the table

SELECT * FROM employee emp a WHERE 3 = (SELECT COUNT(*) FROM employee emp b WHERE a.salary <= b.salary) ;

I made a details comparision set about the operations of query.

Table employee is having the 6 record with salary ranging from 1000 to 6000

Query:
SELECT * FROM employee emp a WHERE 3 = (SELECT COUNT(*) FROM employee emp b WHERE a.salary <= b.salary) ;

Detail Record Condition Check
=====================
1)a <= b
1000<=1000
1000<=2000
1000<=3000
1000<=4000
1000<=5000
1000<=6000
[count=6]

2)a <= b
2000<=1000
2000<=2000
2000<=3000
2000<=4000
2000<=5000
2000<=6000
[count=5]

3)a <= b
3000<=1000
3000<=2000
3000<=3000
3000<=4000
3000<=5000
3000<=6000
[count=4]

4)a <= b
4000<=1000
4000<=2000
4000<=3000
4000<=4000
4000<=5000
4000<=6000
[count=3]

5)a <= b
5000<=1000
5000<=2000
5000<=3000
5000<=4000
5000<=5000
5000<=6000
[count=2]

6)a <= b
6000<=1000
6000<=2000
6000<=3000
6000<=4000
6000<=5000
6000<=6000
[count=1]

Result : 4000 as its count is matching the condition ie. 3

Wednesday, February 15, 2012

Enabling Memcached In Magento

The new local.xml.additional memcached portion that comes standard in Magento now looks like this:
To get memcached up and working, this configuration can be used:


File
memcached

[


memcached
T
his new configuration is similar to the old one with some changes. The option above is set to use files. This acts as a backup mechanism in the event that the primary memcached instance fails. In previous versions of Magento, there was no failover mechanism. If memcached were to die or stop responding, it would result in the entire Magento site to go down.

It is worth noting that the cache could also be set to use a memcached config, If this were the same ip and port of the configuration, the configuration will work but any failover would be negated as a memcached failure would still result in the site going down. As an option, a second memcached instance would be setup to listen on a different port than the default 11211 (or use a local unix socket). This would still allow the to perform “fast” as it is not dependent on file system access. Alternatively you could also use the /dev/shm memory based file system for the set to “file” so if the fast memcached backend failed you would still have faster failover to memory instead of disk.

To further decrease the chances that Magento would fail as result of a memcached failure, Magento does support multiple distributive memcached servers. You can run multiple memcached instances on the same server on different ports (or unix sockets) or if your store is running on multiple servers in a cluster environment, you can run a separate memcached instance on each server. In both of these cases, a single memcached failure will not result in the site going down. A distributive configuration can be placed with in the section and looks like the following:

[ip_of_memcache_server1]
11211
1

[ip_of_memcache_server2]
11211
1

[ip_of_memcache_server3]
11211
1

Please remember to always follow good security practices and never run memcached on an external public ip address. Always run memcached on a local unix socket or localhost. If a clustered environment exists with a private internal network that is in no way accessible from the internet, memcached may be set to listen on those private interfaces.

Generate PDF files in CakePHP using TCPDF

What is TCPDF?
TCPDF is an Open Source PHP class for generating PDF documents.

Its a best way to generate PDF in CakePHP, comparatively any other available helper i ever used.

How to use ?
Below are the steps.

Step: 1 Download and Configure

  1. Go to http://www.tcpdf.org and download the latest version of TCPDF.
  2. Extract to one of your vendors folders, such as app/vendors. It will create a directory tcpdf there with tcpdf.php and more in it. You need at least the folders tcpdf/config and tcpdf/fonts in your application.
  3. Configure TCPDF, see its documentation. You want at least to have a look at tcpdf/config/tcpdf_config.php.
Step 2: Extend TCPDF to customize your header and footer

There is a default header and footer in TCPDF, defined in a header() and a footer() method, which is supposed to be overwritten by you, if needed. This can be done by extending TCPDF and then calling this extended TCPDF class from your application.

In app/vendors create the file xtcpdf.php with this content:

xheadertext = 'YOUR ORGANIZATION';
* set the fill color in the view using
* $fpdf->xheadercolor = array(0,0,100); (r, g, b)
* set the font in the view using
* $fpdf->setHeaderFont(array('YourFont','',fontsize));
*/
function Header() {

list($r, $b, $g) = $this->xheadercolor;
$this->SetY(-290);
$this->SetFillColor($r, $b, $g);
$this->SetTextColor(0, 0, 0);
$this->SetFont('times', '', 14);
$this->writeHTMLCell(-250, '', '', '', $this->xheadertext, 0, 0, false, true, 'C');
$this->SetY(-280);
$this->Cell(0,8, '','T',1,'C');
}

/**
* Overwrites the default footer
* set the text in the view using
* $fpdf->xfootertext = 'Copyright © %d YOUR ORGANIZATION. All rights reserved.';
*/
function Footer() {
$footertext = sprintf($this->xfootertext, $year);
$this->SetY(-20);
$this->SetTextColor(0, 0, 0);
$this->SetFont($this->xfooterfont,'',$this->xfooterfontsize);
$this->Cell(0,8, '','T',1,'C');
$this->SetY(-18);
// write the second column
$this->writeHTMLCell(180, '', '', '', $this->xfootertext, 0, 0, false, true, 'C');
}

}

?>


Step 3: Create your layout for PDF

You cannot use your default layout, as it would wrap the PDF file in your HTML page code. You need a layout such as this one, save it as app/views/layouts/pdf.ctp :


header("Content-type: application/pdf");
echo $content_for_layout;
?>

Step 4: For your Controller

function downloadPdf() {
$this->layout = 'pdf';

Configure::write('debug', 0);
$tcpdf = new XTCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$some_filed = $_REQUEST['some_filed'];
$some_filed = $_REQUEST['some_filed'];
$some_filed = $_REQUEST['some_filed'];
$obj = new SomeHelper();
$Somefiled = ucwords($obj->getSomefiled($brand));
$rowsArray = $obj->SomeFunction($some_filed, $some_filed, $some_filed);
$this->set('tcpdf', $tcpdf);
$this->set('some_filed', $some_filed);
$this->set('rowsArray', $rowsArray[);
$this->render('/reports/procurement/download_pdf');
}
Step 5: For your View

View Template:


$html='';
$slno=1;
$textfont = 'times'; // looks better, finer, and more condensed than 'dejavusans'
//set margins
$tcpdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$tcpdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$tcpdf->SetFooterMargin(PDF_MARGIN_FOOTER);
//set auto page breaks
$tcpdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$tcpdf->setHeaderFont(array($textfont, '', 18));
$tcpdf->xheadercolor = array(255, 255, 255);
$tcpdf->xheadertext = "

Header of the page

";

$tcpdf->xfootertext = "Copy Right Message

";


// add a page (required with recent versions of tcpdf)
$tcpdf->AddPage(); // Front Page

$html_1 = "

$supplier

";


$tcpdf->SetY(-270);
$tcpdf->SetTextColor(0, 0, 0);
$tcpdf->SetFont('times', '', 12);
$tcpdf->writeHTMLCell(-250, '', '', '', $html_1, 0, 0, false, true, 'C');

$curNtDateTime = explode(' ', Date('d-m-Y H:i:s'));
$curDate = $curNtDateTime[0];
$curTime = $curNtDateTime[1];



$lefthtml = "Date: $curDate";

$tcpdf->SetY(-260);
$tcpdf->SetTextColor(0, 0, 0);
$tcpdf->SetFont('times', '', 12);
$tcpdf->writeHTMLCell(-250, '', '', '', $lefthtml, 0, 0, false, true, 'L');


$righthtml = "Time: $curTime";

$tcpdf->SetY(-260);
$tcpdf->SetTextColor(0, 0, 0);
$tcpdf->SetFont('times', '', 12);
$tcpdf->writeHTMLCell(-250, '', '', '', $righthtml, 0, 0, false, true, 'R');

$html = "









";
foreach ($rowsArray as $row) {

$html.= '';
$html.= '';
$html.= '';
$html.= '';
$html.= '';
$html.= '';
}

$html.="
S. Nosome_filedsome_filedsome_filedsome_filedsome_filed
' . $slno++ . '' . $row['some_filed'] . '' . $row['some_filed'] . '' . (int) $row['some_filed'] . '' . $row['some_filed'] . '' . $row['mrp'] . '
";



$tcpdf->setY(-240);
$tcpdf->SetTextColor(0, 0, 0);
$tcpdf->SetFont($textfont, '', 12);

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

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

echo $tcpdf->Output('File_Name.pdf', 'D');
?>


So is it done?
Yeah.. Now you are done ;)
Enjoy!!
References:
http://bakery.cakephp.org/articles/kalileo/2010/06/08/creating-pdf-files-with-cakephp-and-tcpdf