»
S
I
D
E
B
A
R
«
Using ORDER BY with UPDATE
Jul 21st, 2009 by admin

Yep, you read the title correctly. This problem presented itself when I needed a quick and dirty way to update an auto_increment [a_i] field in a database. I wanted to move the a_i field up by n, where a_i > x. The query looked like this:

UPDATE table_name SET id = (id + n) WHERE id > x ORDER BY id DESC

To see why one must do it this way, try to do the query without the SORT BY.

Nick

Yet another example of the ‘perks’ of Socialism
Jul 14th, 2009 by admin

OK, fine, full-blown Socialism does not exist in the UK; however, the UK is definitely more socialized than here in the States. Below, you will find a great ‘perk’ of trying to work with more-socialized countries:

Q: How come other services are not blocked?

We can only really speak for ourselves on this one. There are two rules we follow: to abide by standing copyright laws, and to pay artists fairly.

In the UK, to be a licensed service for all the music we want to play on Pandora, we are being asked to pay per track/stream rates which equate to over 80% of our gross revenues. This licensing framework does not enable any entity to grow an economically viable ad-supported Internet radio business. These rates apply to all Internet radio, or so we have been told. You would have to ask those other companies about how they are still streaming to the UK.

That is from www.pandora.com, one of [if not the] best free-streaming-radio websites available online.

Nick

mysqli_num_rows() functionality
Jul 13th, 2009 by admin

Warning: mysqli_num_rows() [function.mysqli-num-rows]: Function cannot be used with MYSQL_USE_RESULT

Does this error look familiar? Yeah, weird that even though you are using mysqli_, it says MYSQL_; trust me, I know. Instead of using mysqli_use_result(), try mysqli_store_result(). Problem sloved.

Nick

JavaScript and Image Galleries
Jun 10th, 2009 by admin
For one of my recent freelance projects, I was tasked with creating an image gallery. I wanted the gallery to cycle continuously [i.e. - end to beginning when next is clicked, beginning to end when prev is clicked]; however, when the image was loading [i.e. - it is uncached], I wanted a ‘Loading …’ bar to display. I started to overthink the solution at first; however, the solution turned out to be rather easy. Please note, this solution has only been tested in FF3 and IE6.

function updateImage() {
document.location.hash = currentImage;

var image = document.getElementById(’galleryImage’);

image.src = documentRoot + galleryName + currentImage + imageSuffix;

// If the image has fully loaded, we are ready to display
// the image, and take away the loading bar.
image.onload = hideLoading;
}

/*********************************************************/

function showLoading() {
document.getElementById(’loadingBar’).style.display = ‘block’;
document.getElementById(’galleryImage’).style.display = ‘none’;
}

/*********************************************************/

function hideLoading() {
document.getElementById(’loadingBar’).style.display = ‘none’;
document.getElementById(’galleryImage’).style.display = ‘block’;
}

My Fundamentals of Visual Literacy Final Project
May 1st, 2009 by admin
I just realized that I never posted a link to my final project. The site is pretty self explanatory, so enjoy.

You can find the final project here.

»  Substance: WordPress   »  Style: Ahren Ahimsa