ITT #12: Display Random Entries with PHP

I ran into an interesting problem while developing a new blogging system recently where I needed to generate a subset of array elements in random order.

A random subset of elements is useful for displaying a sampling of entries that changes with every page load, such as four random blog entries, a photo gallery that stays interesting even if new photos aren't uploaded, or, if you want to use a sweet content slider, you could show random portfolio or blog entry previews and keep your slider fresh.

Defining the Problem

The Array First things first, we need to know what we're dealing with. For the purpose of this example, we'll be using a multi-dimensional array that looks something like this:

$entries = array( array( 'title' => 'Entry One', 'author' => 'Jason Lengstorf', 'date' => 'April... read more

ITT #11: A Tip for Using Arrays

This week's Instant Tip Tuesday is a short one because I'm under some pretty tight deadlines. I'm still looking for developers to help out by guest blogging on Ennui Design, so contact me if you'd like to show your developing chops!

On a quick vanity note, Chad Engle did an interview with me over on the DCTH site, so head over there and check that out!

Manipulate Arrays to Handle the First Element Differently

Arrays, though they're incredibly useful, can also easily become confusing. This is especially true when dealing with multi-dimensional arrays, like a collection of entries from a database (a blog, for instance, would have at least two dimensions in an array of entries: each blog is an array of the different pieces of the blog, such as title, author... read more

ITT #10: Understanding OOP

NOTE: This comment by Cal Evans pointed out an oversight on my part regarding naming conventions for classes. To avoid conflicting with other classes, names should be distinctive, and as such, I changed the name of the example class from "date" to "Ennui_Date".

Recently, I've fielded a handful of questions concerning object-oriented PHP. What is it? How does it work? Why should we care?

I had similar questions when I first started looking at OOP. I mean, why the hell would I want to switch from the easy-to-understand procedural method?

Classes and objects might look confusing and difficult to manage at first, but they actually significantly improve the organization and readability of your code if used properly.

A Practical Example

Let's say, for instance, that we need to be... read more

ITT #7: Dynamically Change Width and Height in HTML Markup

A Quick Note from the Guest Author Hello everyone, I'm Brenley Dueck or better known as Brenelz. I currently run my own business called Brenelz Web Solutions which focuses primary on web design in winnipeg. The web technologies I most specialize in are CSS, jQuery, AJAX, PHP, and the MySQL database. Please make sure to visit my web design blog and follow me on twitter.

Defining the Problem

In a recent project I was working on we had to allow the client to embed videos within the site. This had to be done using an easy-to-use customized CMS. The thought is that they can take the embed code right off the YouTube site and save it to the DB for use throughout the site.



YouTube's... read more