Skip to main content

Posts

Huge data Excel download using PHP

Ah! It was always a problem to download huge data in excel format. Tried the best library available 'PHPExcel' but the issue persists with memory limit and time taken to generate and download. But here is the promising solution found after spending ages searching on Google. You can find it here . The author himself says "Never run out of memory with PHPExcel again". You need to download it and include  xlsxwriter.class.php   where you want to fetch the data from DB and through it on to browser or save to a particular location. Let's get started. Below is the logic to generate the file and store in the current directory. If you want to store is at the desired location, specify the location for the method writeToFile. include_once("xlsxwriter.class.php"); $writer = new XLSXWriter(); $data = array( array('year','month','amount'), array('2003','1','220'), array('2003','2'...

WYSIWYG super light editor with jQuery & Bootstrap

Yes! It is. Summernote is the super light WYSIWYG editor for the web. It supports most of the features tinyMCE or CKEditor does but with smallest Javascript & CSS files. You can download Summernote from here . It is the official website for the same. It has very simple getting started tutorial.  This is article will show you how to start with summernote and couple of fixes or plugin which you don't find on the official website. Getting started: If you want to download and start with, click here . For CDN, place below snippet under head tag. <!-- include libraries(jQuery, bootstrap) --> <link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.css" rel="stylesheet"> <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script> <script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.js"></script> <!-- include summernote css/js --...

Web Developer Roadmap

Credits

Generate documentation for PHP Code using phpDocumentor

What is phpDocumentor? phpDocumentor is the simple and best tool to generate API documentation for PHP source code.  Downloading & installing phpDocumentor: There are several dependencies to install phpDocumentor you can find them on official website i.e., here To install phpDocumentor using PEAR type below command In windows, run command prompt as administrator. Goto xampp/php folder and type pear channel-discover pear.phpdoc.org pear install phpdoc/phpDocumentor In linux, open terminal and type (if install xampp for linux then goto xampp/bin folder) pear channel-discover pear.phpdoc.org pear install phpdoc/phpDocumentor Generate API using phpDocumentor: In windows, goto  phpdoc.bat folder and run phpdoc  command for source directory to destination phpdoc -d <source directory of php code> -t <destination directory> In Linux, goto [phpdocumentor installation folder]/bin/ and run command phpdoc -d <source directory of php...

Google like Pagination

In the beginning of my career, every technical interview has this question; "How do you write pagination script in PHP?". I think you too faced the same issue. It was very important to answer this because every application is developed to list set of information and off-course you can't show every thing in a single page. It will irritate the user to scroll to the bottom of page to read. So, the pagination. Divide the list of items in number of pages and navigate to each by clicking on each page number displayed. At the beginning, the pagination was simple was limited to 10-15 pages, but after some time in real time the requirement has grown to 10 multiple pages. Solution was to show first few page numbers, last few page numbers and in middle show the ellipsis(...). As you navigate to any page it would show definite page numbers to both the sides. /** * Pagination file * * This file provides the google like pagination solution * * @category Saral * @packag...

Validation and Submission of form using jQuery :: Easiest Solution

In any application, form validation and submission to server is so common and redundant; there are multiple ways of doing it. And the best and easiest way that I do use or recommend is jQuery solution.  Most popular jQuery plugins are the best solution, they have the best solution ever.  One, jQuery Validator written and maintained by Jorn Zaefferer, a member of the jQuery team, lead developer on the jQuery UI team and maintainer of QUnit. Two, jQuery Form by malsup, it has various plugins and solutions. Another plugin that I like from same developer is jQuery BlockUI . (give a try). Name: Email: Note: To avoid unexpected behavior, maintain same form and fields names and id selector values. Need further explanation, let me know.

Email already exists using jQuery

It is the common requirement for any web application either it is PHP, .net, JSP etc., which has users involved. When creating/adding user from admin or end user registration we should check whether username or email address already exists. It will help to have unique registrations to our application and avoid confusion between various users.  I see many developers struggle with this by submitting the form to server side script and validate their from database, in case username/email address already exists they take the pain to go back to previous page or form and show the error message with other form data filled.  Few use AJAX to send the information onblur or onkeyup or onkeydown but face difficulties to stop form submission. Here is the simple solution that would help in validating username or email address existence without much hassle.  Solution comes from popular jQuery Validator plugin I'm using this from ages.  HTML Code: <html> <head...