»
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

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’;
}

Eames Cards
Oct 26th, 2008 by admin

The theme that I chose was locations and buildings in Kansas. I used the purple to accent the photo, and tried to pick something in the photo that was already ‘attention grabbing’.

Nick

Courthouse in Colby, KS

Rodeo in Dodge City, KS

Some Fireworks Fun
Sep 8th, 2008 by admin

Nick

»  Substance: WordPress   »  Style: Ahren Ahimsa