Formatting a multi-level menu using only one query

By crisp on Sunday 23 December 2007 23:46 - Comments (22)
Category: PHP, Views: 59.536

In the programming forum (dutch) on Gathering of Tweakers I often see people struggeling with multi-level menu's stored in a database and the formatting of such menu in HTML.

This is actually quite a common programming problem that can be solved using some kind of recursion or stack-based processing in order to create a tree out of a flat datastructure containing parent-child relations. However, in most cases the final solution that is presented involves seperate queries being executed inside a loop or inside a function that is called recursively which retrieves the child-elements for a specific parent. In situations where the menu has many items and/or has many levels this could easily result in dozens of queries being executed only to generate something simple as a treelike-output.

I would like to show you how this can be done using only a single query.

Read more »

Banners en browsing performance impact nl

Door crisp op maandag 17 december 2007 00:06 - Reacties (13)
Categorie├źn: Internet, Tweakers.net, Views: 12.715

Het zal niemand verbazen dat reclame op websites (banners) een negatieve impact hebben op de 'browsing performance': je moet immers meer data ophalen en dat moet ook nog eens allemaal gerendered en getoond worden door je browser.

Lees verder »

Microsoft, where are you?

By crisp on Saturday 8 September 2007 11:49 - Comments are closed
Category: Browsers, Views: 6.791

Alex Russell asks "Where are we now?" a year after the introduction of IE7. Now that IE7 is slowly taking over the landscape from IE6 it is time to look forward again. After all IE7 didn't bring us much new, it just barely managed to take the edges off of the pain we developers have been enduring with IE6 for a long time.

Read more »

Crossbrowser Array Generics

By crisp on Monday 20 August 2007 00:06 - Comments (2)
Category: Javascript, Views: 8.349

I briefly demonstrated how one can use an array method on non-array objects such as nodeLists or the arguments variable in my previous entry on getElementsByClassName (and Menno van Slooten did me a favour by explaining it on his blog). I also used the Array generic Array.filter there and left those with a promise to explain how these techniques can be implemented crossbrowser.

Read more »

getElementsByClassName re-re-re-visited

By crisp on Monday 13 August 2007 09:07 - Comments (3)
Category: Javascript, Views: 15.122

There have been numerous attempts at creating the most optimal getElementsByClassName implementation. I also took a shot at it back in 2005 and back then Opera had some performance problems with getElementsByTagName, IE's implementation of nodeList.item() proved to be a major hog and Firefox' XPath implementation was far from perfect. Eventually I came up with a hybrid solution that combined the fastest approaches for each tested browser (with IE being declared the winner on performance).

Read more »