Monday, May 31, 2010
Top 10 AJAX,PHP,MYSQL Based Data Grid
http://www.webhostingbreak.com/top-10-ajax-php-powered-mysql-table-editor-viewer-data-grid/
Simple way of Exporting HTML Page Data to Excel
Just follow the below code and write down at bottom portion of your pages that u want to export data to excel. You dont have to do anything else....You r DONE !!
Step 1 :
copy paste the below code at the bottom of your page.
$filename = "mis_datewise_monitoring_data.xls";
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");
exit(); //remember to stop output unless you do it its own file.
Step 2:
name your excel file that u want to export data always. then create a button like export to excel.
Suggestions:
It is better to use another page for exporting html data like php mysql result will load in a page and exporting of the same data will be done from another page. You need to pass the Value of your desire through URL from current page to excel export page. Hope it is clear to you.
enjoy php...
Step 1 :
copy paste the below code at the bottom of your page.
$filename = "mis_datewise_monitoring_data.xls";
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");
exit(); //remember to stop output unless you do it its own file.
Step 2:
name your excel file that u want to export data always. then create a button like export to excel.
Suggestions:
It is better to use another page for exporting html data like php mysql result will load in a page and exporting of the same data will be done from another page. You need to pass the Value of your desire through URL from current page to excel export page. Hope it is clear to you.
enjoy php...
Thursday, April 1, 2010
Simple Html 2 pdf using php
The following is a nice alternative for those who need to generate dynamic PDF documents on-the-go. This class does not require any PDF extensions to be loaded in the PHP configuration.
The class is simple to load and use right away. You can find the class and it’s documentation on it’s website here: http://html2fpdf.sourceforge.net/
It is based upon (F)PDF which you can find here: http://www.fpdf.org/
You can download a usable version directly from here
The purpose of this class is to make the creation of PDF documents from HTML formatting easier, and it does the job fairly well. It seems to understand many of the most important HTML elements, as well as some CSS.
An example of simple usage:
Create a new page with text like hello world, test and save it as test.php
SetTopMargin(1);
$pdf->AddPage();
$pdf->WriteHTML($html);
$pdf->Output('test.pdf','D');
?>
to view details tutorials at - http://thronic.com/2008/development/simple-html-2-pdf-using-php/
The class is simple to load and use right away. You can find the class and it’s documentation on it’s website here: http://html2fpdf.sourceforge.net/
It is based upon (F)PDF which you can find here: http://www.fpdf.org/
You can download a usable version directly from here
The purpose of this class is to make the creation of PDF documents from HTML formatting easier, and it does the job fairly well. It seems to understand many of the most important HTML elements, as well as some CSS.
An example of simple usage:
Create a new page with text like hello world, test and save it as test.php
SetTopMargin(1);
$pdf->AddPage();
$pdf->WriteHTML($html);
$pdf->Output('test.pdf','D');
?>
to view details tutorials at - http://thronic.com/2008/development/simple-html-2-pdf-using-php/
PHP Export Excell without saving a file
A simple way of exporting data to the web in excel format, you don’t have to create an excel file, you just have to define the proper headers for the browser.
First define a filename, and headers.
$filename = "test.xls";
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");
Now just send the clear text data you want the excel file to contain, use “\n” and “\t” for row and column navigation.
For example:
echo "column1 \t column2\n";
echo "row1 value1" . "\t" . "row1 value2\n";
echo "row2 value1" . "\t" . "row2 value2";
exit(); //remember to stop output unless you do it its own file.
Click the link below to see how the export of this data would look like.
http://thronic.com/pubfiles/export_excel_example.php
courtesy: Dag J. Nedrelid
First define a filename, and headers.
$filename = "test.xls";
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");
Now just send the clear text data you want the excel file to contain, use “\n” and “\t” for row and column navigation.
For example:
echo "column1 \t column2\n";
echo "row1 value1" . "\t" . "row1 value2\n";
echo "row2 value1" . "\t" . "row2 value2";
exit(); //remember to stop output unless you do it its own file.
Click the link below to see how the export of this data would look like.
http://thronic.com/pubfiles/export_excel_example.php
courtesy: Dag J. Nedrelid
Monday, March 29, 2010
Ajax autocomplete using PHP & MySQL
Today I have decided to implement an Ajax (jQuery) auto complete feature in PHP & MySql. jQuery makes remote scripting a piece of cake and that led me to spend more time coding additional functionalities for the auto-complete field. In this post i'll explain how to use my autocomplete field and in a following post i will explain all the code. So lets start!
Before continuing lets see My Demo to how it will work.
Besides the auto-complete code we need the jQuery library along with its Dimensions plug-in (all files are included in the zip files). Let’s include in the head of your page:
Now we need to call the function that will bring data to our auto-complete field - setAutoComplete.
The call to setAutoComplete is inside a jQuery special code that is only executed when the DOM is ready, or in other words, when all the code is already loaded. The setAutoComplete function takes 3 parameters:
Now we include our stylesheet to define the look of the elements. We need to define the styles of the div that will contain the results, they include two classes for the selected and unselected items. Take a look at the CSS file linked at the end of this post. There is also a style for the input field.
To finish the client side part now we need to define the code of the input field as follows:
Now that the client side is finished it’s time for the server script. Here is an example of a script that try to match colors. I’m using PHP but you can use whatever language you prefer for the job, of course. You just need to return the results as an array encoded as JSON.
Courtesy: Sujit Kumar Shah
Before continuing lets see My Demo to how it will work.
Besides the auto-complete code we need the jQuery library along with its Dimensions plug-in (all files are included in the zip files). Let’s include in the head of your page:
The call to setAutoComplete is inside a jQuery special code that is only executed when the DOM is ready, or in other words, when all the code is already loaded. The setAutoComplete function takes 3 parameters:
- the id of the input field
- the id of the div that will hold the returned data
- the URL of the remote script that will process the request
Now we include our stylesheet to define the look of the elements. We need to define the styles of the div that will contain the results, they include two classes for the selected and unselected items. Take a look at the CSS file linked at the end of this post. There is also a style for the input field.
To finish the client side part now we need to define the code of the input field as follows:
Now that the client side is finished it’s time for the server script. Here is an example of a script that try to match colors. I’m using PHP but you can use whatever language you prefer for the job, of course. You just need to return the results as an array encoded as JSON.
$link = mysql_connect('localhost', 'dbUsername', 'dbPassword');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
if (!mysql_select_db("database")) {
echo "Unable to select mydbname: " . mysql_error();
exit;
}
$result = mysql_query("SELECT name FROM sks_color");
while ($row = mysql_fetch_assoc($result)) {
$colors[]=$row['name'];
}
mysql_free_result($result);
mysql_close($link); // check the parameter
if(isset($_GET['part']) and $_GET['part'] != '')
{
// initialize the results array
$results = array(); // search colors
foreach($colors as $color)
{
// if it starts with 'part' add to results
if( strpos($color, $_GET['part']) === 0 ){
$results[] = $color;
}
} // return the array as json with PHP 5.2
echo json_encode($results);
}
Now every things done! As said before, we return the data as an array encoded as JSON. If you are running PHP >= 5.2.0 or the json extension you simply use json_encode for the job.if (!$link) {
die('Could not connect: ' . mysql_error());
}
if (!mysql_select_db("database")) {
echo "Unable to select mydbname: " . mysql_error();
exit;
}
$result = mysql_query("SELECT name FROM sks_color");
while ($row = mysql_fetch_assoc($result)) {
$colors[]=$row['name'];
}
mysql_free_result($result);
mysql_close($link); // check the parameter
if(isset($_GET['part']) and $_GET['part'] != '')
{
// initialize the results array
$results = array(); // search colors
foreach($colors as $color)
{
// if it starts with 'part' add to results
if( strpos($color, $_GET['part']) === 0 ){
$results[] = $color;
}
} // return the array as json with PHP 5.2
echo json_encode($results);
}
Courtesy: Sujit Kumar Shah
Saturday, March 20, 2010
Step by step guide to install component in Joomla
Step By Step Installation of Joomla 1.5 component
Hello World
Introduction:
A "hello world" program is a classic software program that prints "Hello world!" on a display device. It's very popular introductory tutorial for teaching a programming language or an application framework. Such a program is typically one of the simplest programs possible.
This Joomla 1.5 "hello world" component is not an exception. I will keep it as simple as possible. The main purpose of this component is to encourage joomla developers to implement joomla 1.5 components and my personal goal is to sort out my thoughts of "clean" component. Believe or not I' m also just a joomla developer learner.
If you have any comments please go to developers joomla1.5 forum My next tutorial will be "hello world" using the new MVC framework included in Joomla! 1.5, so keep in touch.
- Install joomla 1.5 beta 1
-my personal tip is to use xampplite http://www.apachefriends.org/en/xampp.html this package contains all we need to try joomla.
Pros :
Pros :
- it doesn't install any rubbish
- we don't need to be afraid of getting interfere with our registry or services
- easy to install
- simple and portable (pack, copy, unpack, use; easy to change a directory path)
- Download component from website http://www.vojtechovsky.net/joomla/com_helloworld.zip
- Log in joomla as Administrator user
Extensions->”Install/Uninstall”
- Press “Browse” button and find you downloaded file com_helloworld.zip on your computer.
- Install component by pressing “Upload File & Install“button.
- Test Administration module
- Make menu for our new component
Menus -> Main Menu -> New -HelloWorld(double click) ->Name: Show me HelloWORLD!
- Let's show me new component
Go to your joomla website and click on Show me HelloWORLD!link
- What about component localization?
You will need to have installed czech language package. It's not finished in joomla 1.5 yet so let's cheat a little.
Copy “cs-CZ” folder from your joomla installation folder (e.g. c:\web\xampplite\htdocs\j15\installation\language\cs-CZ) to your language folder and your administrator language folder. (e.g. c:\web\xampplite\htdocs\j15\language\cs-CZ and c:\web\xampplite\htdocs\j15\administrator\language\cs-CZ )
If you didn't prepare it before the component instalation you have to uninstall/install the component.
Let's make some testing.
Go to Administrator section and select Czech language for both site/administrator as DEFAULT!

Go to component administration/joomla site and see the component text in czech.

If you didn't prepare it before the component instalation you have to uninstall/install the component.
Let's make some testing.
Go to Administrator section and select Czech language for both site/administrator as DEFAULT!
Go to component administration/joomla site and see the component text in czech.
- Check out the joomla system log file
[joomla folder ] + \logs\error.log
(e.g. c:\web\xampplite\htdocs\j15\logs\error.log )
#Version: 1.0
#Date: 2007-02-06 16:51:17
#Fields: date time level c-ip status comment
#Software: Joomla! 1.5.0 Beta [ Khepri ] 12-Oct-2006 00:00 GMT
2007-02-06 16:51:17 0 127.0.0.1 1 hellodefault :Hello World. I just finished my first Joomla 1.5 component.
2007-02-06 16:51:26 0 127.0.0.1 1 helloworld :Hello World
2007-02-06 16:51:29 0 127.0.0.1 1 helloagain :Hello Again
2007-02-07 17:03:18 0 127.0.0.1 1 helloagain :Hello Again
2007-02-07 17:03:20 0 127.0.0.1 1 helloworld :Hello World
2007-02-07 17:05:00 0 127.0.0.1 1 helloworld :Ahoj Světe
2007-02-07 17:05:03 0 127.0.0.1 1 helloagain :Ahoj Znova
2007-02-07 17:05:11 0 127.0.0.1 1 helloworld :Ahoj Světe
2007-02-08 16:55:54 0 127.0.0.1 1 helloworld :Hello World
2007-02-08 16:55:58 0 127.0.0.1 1 helloagain :Hello Again
2007-02-08 16:56:14 0 127.0.0.1 1 hellotestfoo :Ahoj Světe, moje první testovací funkce byla právě spuštěna.
(e.g. c:\web\xampplite\htdocs\j15\logs\error.log )
#Version: 1.0
#Date: 2007-02-06 16:51:17
#Fields: date time level c-ip status comment
#Software: Joomla! 1.5.0 Beta [ Khepri ] 12-Oct-2006 00:00 GMT
2007-02-06 16:51:17 0 127.0.0.1 1 hellodefault :Hello World. I just finished my first Joomla 1.5 component.
2007-02-06 16:51:26 0 127.0.0.1 1 helloworld :Hello World
2007-02-06 16:51:29 0 127.0.0.1 1 helloagain :Hello Again
2007-02-07 17:03:18 0 127.0.0.1 1 helloagain :Hello Again
2007-02-07 17:03:20 0 127.0.0.1 1 helloworld :Hello World
2007-02-07 17:05:00 0 127.0.0.1 1 helloworld :Ahoj Světe
2007-02-07 17:05:03 0 127.0.0.1 1 helloagain :Ahoj Znova
2007-02-07 17:05:11 0 127.0.0.1 1 helloworld :Ahoj Světe
2007-02-08 16:55:54 0 127.0.0.1 1 helloworld :Hello World
2007-02-08 16:55:58 0 127.0.0.1 1 helloagain :Hello Again
2007-02-08 16:56:14 0 127.0.0.1 1 hellotestfoo :Ahoj Světe, moje první testovací funkce byla právě spuštěna.
courtesy: http://www.vojtechovsky.net/joomla/
Subscribe to:
Posts (Atom)