For work we needed a way to allow the customer to preview what their Bible imprint text would look like before they placed their order. I’m sure there are ways to do this with JavaScript, but we chose to do this with PHP to prevent the site from relying on Javascript (there was already enough [...]
I’m just finishing up a little project to improve the search ability on a website and I want to display an image and message say “loading…” until the script finished running. Below is an easy way to do that.
First just make sure you have the latest version of jQuery.
$(document).ready(function () {
$.get(“script.php”, { keyword: “linein”},
function(data){
document.getElementById(‘text_box’).innerHTML = [...]
Here’s the follow-up article on how to easily get file sizes nicely formated. Below is a quick function that will display the file size in KB, MB, or GB all easily accessed through a function.
function formatbytes($file, $type)
{
switch($type){
case “KB”:
$filesize = filesize($file) * .0009765625; // bytes to KB
break;
case “MB”:
$filesize = (filesize($file) * .0009765625) * .0009765625; // bytes [...]
Below is a quick PHP function that allows you to find the time between two dates. The dates must be in seconds from Unix Epoch.
if(!function_exists(timeBetween))
{
function timeBetween($start_date,$end_date)
{
$diff = $end_date-$start_date;
$seconds = 0;
$hours = 0;
$minutes = 0;
if($diff % 86400 0)
{
$rest = ($diff % 86400);
$days = ($diff – $rest) / 86400;
[...]