Here’s a method to check in a smarty template if it was the last page of page results. {if $listings.current_page gte ($listings.total / $results_per_page)|ceil} True {else} False {/if} where $listings.current_page is the current page user is on, $listings.total is the…
Category: PHP
Formatting date in a php smarty template
The date string can be formatted in a smarty template like this: $payment.creation_date|date_format:”%d-%m-%Y” where creation_date is an element of $payment array.
An advanced HTML to PDF conversion using ezpdf php class
Posting a link to the working example of HTML Form to PDF using “ezpdf” php class. I added some code to this class in order to create more advanced HTML tables cells with borders as shown in the output PDF…
How to debug a php application in production/live mode
How to debug a live website built in php? Here’s a basic, simple and custom method i usually use to debug live or production web applications (web sites). First of all i place the following lines of code in a…
Re-sizing image by width using php
A simple yet very useful function to re-size image by maximum width while keeping width and height in proportion. You just need to pass the maximum width allowed to this function and this function will return you an array containing…
Creating rss feed dynamically and merging it with another rss feed
Recently i generated a rss feed from business listings for one of my client’s website. Also, i merged this listings feed into client’s existing blog rss feed. Here’s how i did it.
Validating php multiple-value checkbox form element with javascript
In php a multiple-value form element such as checkbox is named suffixed with a set of square brackets. For example, My commonly used colors are: <form action=”index.php” name=”myform” method=”post” onsubmit=”return validate_form();”> <input type=”checkbox” name=”colors[]” value=”red” /> <input type=”checkbox” name=”colors[]” value=”green”…
Choosing a business listing directory script written in php
How to Choose a business listing directory script written or coded in PHP programming language I got a new client today who wanted a brand new website equipped with business listing directory feature. According to him, the script should be…
phpMyAdmin PHP Code Injection Exploit attempt on my server
This morning, when i checked my Give Back India site’s access log i found some scripts/setup.php request attempts. In fact, not ‘some’ but hundreds of them. All requests were made targeting phpMyAdmin’ installations on my server. Here are a few…
Converting a text string into comma separated words
Today, i was looking at some old code of mine to find something when i found this little but useful piece of code which i had written for one of my old projects (and of course when i didn’t had…