Archive for the ‘PHP’ Category

Smart Image Resizing In PHP

Monday, December 13th, 2010

Have you ever needed one image in many different sizes on a website? I know I have many times and have never found a good way to handle this until now!

In the CMS’ you build do you have the user upload different sizes of images? Maybe a large image, and a thumbnail. Wouldn’t it be so much nicer if you could have them upload the large image, and then you use whatever sizes of that image you need? Here is how:

Download the Smart Image Resizer Script

Download the zip file here

This smart image resize technique is really handy in that there is only ONE file you need to worry about.

Install the Script

  1. Unzip on your web server
  2. In the same directory, create a directory called “imagecache”
  3. Make your imagecache directory is writable by the web server (usually chmod 775)

Features

  1. Resizes any filetype
  2. Can crop to the ratio you need
  3. Built-in caching abilities to speed up performance.

Usage

This is a breakdown of how it is used:

<img src="/image.php/image.jpg?width=200&amp;height=200&amp;image=/full/path/to/image.jpg" alt="" />

The above code will use the “width” and “height” parameters as the max the image should contain. So the image might be 200px wide but only be 150px tall in order to keep the original ratio.

Now if we wanted to crop our image into a square no matter what the ratio is we would add on another parameter called “cropratio” as follows:

<img src="/image.php/image.jpg?width=200&amp;height=200&amp;image=/full/path/to/image.jpg&amp;cropratio=1:1" alt="" />

*** Please note that the image parameter (/full/path/to/image.jpg) must be the full path from the document root to the image.

Having Problems?

If you are having problems check out the shifting pixel’s page.

Posted in PHP | 1 Comment »

Creating a Sleek Calendar

Wednesday, August 4th, 2010

In this tutorial we are going to create sleek calendar using php with a good looking UI and a navigation. Let’s get started !!

Setting up workspace -

  • Basic knowledge of php, html and css.
  • Local server installed on your PC.

Step 1

First of all create the project folder on your server and inside it create a php file.
(more…)

Posted in PHP, Software, Web Programming | 4 Comments »

MVC: A Beginner’s Guide

Tuesday, December 29th, 2009

Introduction

So you want to learn about MVC? This article will hopefully clear some of your possible confusion when it comes to this three letter acronym that can strike fear into the hearts of many. Like most topics in web development, it’s always a little confusing when you first take a look at it, but after you read up on the topic, and try it for the first time, it’s as easy as pie! Read on, my friend!

What the heck does it stand for?

MVC stands for Model-View-Controller. It is an architectural pattern used when engineering software. Basically, it separates the three main parts of an application and makes them independent of each other, therefore they can be designed, tested, and worked on independently of each other.

In the world of web development, MVC is usually used with a framework such as CakePHP or CodeIgniter. For the purposes of this post, we won’t be focusing on any individual framework, more on the idea of what MVC really is and how it can be used. If you would like to delve into one framework as a beginner, though, I highly recommend CodeIgniter to get started. It is simple, yet powerful, and won’t confuse you when you’re getting started.

M

Models are very simple. They are the knowledge of your program, they represent it as either a single object, or a structure of multiple objects.

In the static web world, your model could be simply the HTML of your page. It is the skeleton of your content, how it will be structured, and of course, the content itself.

V

The view is a visual representation of a model. In a program, a view fetches the model’s data, and displays it. It can also update the model by collecting data.

A static example of this is plain old CSS. The CSS adds visual style to your model (the HTML), it is used as the “skin” to the skeleton of your content. We can switch from one style to another and not affect the model at all.

C

The controller is what puts it all together between the user and the system. It receives user’s input in the form of commands and data, then outputs the views that are to be presented.

An example of the Controller would be the browser. It takes the HTML, CSS and any other jargon and outputs a readable web page for the user to interact with. It can also accept user input in a sign up form for example.

Conclusion

Hopefully I haven’t confused you too badly, and you have at least a basic understanding of MVC now. It’s literally all around you, as I have shown in a simple HTML/CSS/Browser example. If you want to read more, the CodeIgniter documentation explains it in terms of their own framework. Take a look at those docs here. Thanks for reading!

Posted in PHP, Web Programming | 5 Comments »

Implementing paging using PHP and jQuery

Wednesday, December 2nd, 2009

preview

In this tutorial we are going to implement paging using php and jquery. We are going to create a paging widget and we will give it a cool UI using jquery UI. I have tried to explain paging in the most simplest way and it can be extended further easily to more advance form of paging.
(more…)

Posted in PHP, Web Programming | 12 Comments »

How to Create a Simple API with PHP and MySQL

Monday, November 30th, 2009

Introduction

Hello and welcome to my first article for the Brenelz Web Solutions blog! This article will cover how you can create a very simple API for any one of your projects. We are going to be using PHP and MySQL for the back end, and we will output our API data in two formats: XML or JSON.
(more…)

Posted in PHP, Web Programming | 25 Comments »

 
connect with me!