Archive for the ‘PHP’ Category

DataTables is a jQuery plugin to visualize table that is pretty much awesome and has lot of features. Now, I want to talk about TableTools, an extension which has function to export data into files such as CSV, Excel, or PDF.  Here’s a screenshot:

The configuration of TableTools is pretty much easy, you just need litte additional code onto DataTables javascript code:

$('#mytable').dataTable({
    "sDom": 'Tlfrtip',
    "oTableTools": {
    "sSwfPath": "<!--?php echo $this--->config->item('base_url');?>application/libraries/jQuery/plugins/DataTables-1.8.1/media/swf/copy_cvs_xls_pdf.swf"
    }
});

Code at above, mytable is id of your table, and you should add “sDom”: ‘Tlfrtip’ for DataTables DOM display’s configuration, and the last (and the most important), add “sSwfPath”: “yourpath/copy_cvs_xls_pdf.swf”.

Notice the sSwfPath has absolute value (On the code above, i used CodeIgniter).  If you don’t specify this path correctly, TableTools won’t work.

Advertisements

Xdebug on Apache Webserver

Posted: July 28, 2011 in PHP
Tags: , , , , ,

Xdebug is necessary if you want to debug php website. Xdebug comes with a single dll file that is attached to Apache Webserver directory. It looks simple but it could be complicated in practical ways.

My notebook is running Windows 7 x64 and using Apache bundled with Xampp, so i download x64 bit of Xdebug, i didn’t realized this was wrong. Actually my Apache is x86 version so what i really needed is Xdebug x86 :)

Then what i did was copied my Xdebug dll file into C:\xampp\php\ext and then added this lines into php.ini file:

zend_extension="\xampp\php\ext\php_xdebug-2.1.1-5.3-vc6.dll"
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000

Here’s a screenshot produced by php_info() :

A trick to know what Xdebug version that suits Apache version is quite simple, go to this page http://xdebug.org/find-binary.php, ctrl+c and ctrl+v your html code of php_info() .

Connecting PHP into MySQL

Posted: April 15, 2009 in PHP, Programming
Tags: ,

images

It is very simple :

    

<?php
        $host = "my_host";
        $user = "my_username";
        $pass = "my_password";
        $database = "my_database_name";

        mysql_connect($host, $user, $pass) or die ("sorry...connection failed");
        mysql_select_db($database);
?>