Code Is Poetry

Life is Binary

Posts

Creating csv file using php

For report creation it is often necessary to create csv files. It can be done in following way: // output headers so that the file is downloaded rather than displayed header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=data.csv'); // create a file pointer connected to the output stream $output = fopen('php://output', 'w'); // output the column headings fputcsv($output, array('Column 1', 'Column 2', 'Column 3')); //...

Read more

Changing timezone in php

code is as follows:   date_default_timezone_set('Asia/Dhaka'); Full list of timezones are as follows http://www.php.net/manual/en/timezones.php  

Read more

Deleting from large table using LIMIT

Deleting from large table is done using limit. DELETE FROM TABLE_NAME LIMIT 10000; If you need to delete rows of a table based on reference table, You can use condition as well DELETE FROM TABLE_NAME WHERE tbl_field IN ( SELECT tbl_field FROM REF_TABLE_NAME ) LIMIT 10000;

Read more

Applications: How long does it take......?

Pattern: how long does it take by..... from....to... Example: How long does it take by plane from London to Madrid? It takes two hours by plane from London to Madrid. How long does it take by car from house to Bashundhara shopping mall? It takes one hour by car from house to Bashundhara shopping mall. Pattern: how long does it take....to... Example: How long does it take you to fly from London to Madrid? It takes me two hours to fly from London to Madrid

Read more

Creation of linked result with jQuery ui autocomplete widget

jQuery ui plugin has vastness of use cases . One of it are autocomplete widget. Following is code of this implementation loading external data source.   // jquery ui source link <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/themes/smoothness/jquery-ui.css" /> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js"></script> // html part <input type="text"...

Read more

A word about Shopping cart abadonment

Online buying of product is getting more and more popular. Customers go to online and buy products using virtual cart. But survey shows 80% of them does not complete their transaction after that. So, products selected by customers stays in the cart. This is called shopping cart abandonment. Following is a nice topic reference on shopping cart abandonment for selling tickets via online. http://www.eugeneloj.com/2011/01/how-to-sell-more-tickets-for-your-event.html

Read more

Adding days to a date

It is very simple adding days to dates. Example: $date1 = '2007-03-24'; $latest_date = date("M|j", strtotime("+1 days", strtotime($date1)));

Read more