Filipino Programmer | Philippines

Just another Filipino Programmer’s blog by Nick Fernandez III, on web development using PHP in LAMP framework and random information about everything I would tought interesting on and off the IT world.

Random Bytes:
A friend is never a coincidence in your life, they are meant to enter your life to bring you joy and laughter.

Archive for September, 2007


Upcoming Youtube Artist

This female musician/songwriter I have stumbled upon Youtube is worth listening to. She is known as Daisy, GUIZELLADAY, or MizzDAIZYD, this Australian beauty (with Asian features) is truly amazing. She writes and sings her own song, I do sometimes feel she sings like Avril and I really love the Alternative/Acoustic touch on her songs. As a tribute to her songs and talent, here is one of her latest composition and one of my favorite songs of her.

Tainted (Original)
by: Daisy

Lyrics:

(Daisy): Tainted….Have you ever had a small stain? And it just ruin everything. You can’t forget it. You might want to throw it away.

Oh, oh, oooohh…..
Yeah…yeah..yeah….
Oh, oh, oooohh…..Baby…

Alone tonight,
I called you up and said hey boy, come over here
and spend the night baby with me
but then i realized it was a bad idea,
it’s just the wine talking and another day will come
and our issues will still be here

* Refrain:
here we go again,
is it ever gonna change?

**Chorus:
Everything about you and me
Seems so dated, it’s so tainted
Everything about you and me
Seems so hazy, it’s so crazy
Could’ve been sweet, but there was just a small stain
Slightly incomplete
There’s something missing, something missing
We could try again but the damage still remains
I don’t know how to change
That’s why it’s over
Everything about you and me
Seems so jaded, it’s so tainted

Don’t wanna fight
I called you up and said hey boy stay over there
cause tonight I’m needing room to breathe
You saying it’s alright, gonna see and old girlfriend
Goin’ out for the evening and another day will come
when you’re thinking ‘i should have been there’

Repeat * (Refrain) and ** (Chorus)

Oh, oh, oooohh…..
Yeah…yeah..yeah….
Oh, oh, oooohh…..Baby…

here we go again
is it ever gonna change?

Everything about you and me
Seems so dated, it’s so tainted
Everything about you and me
Seems so hazy, it’s so crazy, crazy, crazy
Could have been sweet, but there was just a small stain
Slightly incomplete
There’s something missing, something missing
We could try again but the damage still remains
I don’t know how to change
That’s why it’s over
Everything about you and me
Seems so jaded, it’s so tainted…

(Daisy) : I hate feeling, who doesn’t hate feeling?

You can also check her myspace account for studio version of her original songs:
www.myspace.com/mizzdaizyd

Bookmark This!

del.icio.us Digg Google StumbleUpon Technorati

3 New Printing Technology in Japan

1. Micro Printing

The tiny book featured on this clip is 0.95mm by 0.95mm, though the book might seem useless, this technology enables countries like Japan to produce a new paper currencies that are harder to counterfeit. The application for this technology is limitless.

2. 3D Printer

The examples shown in this video include a life-like reproduction of a melon and a model of a house (including the interior of the building!). At a price of just under 40 thousand dollars, this printer makes color 3D printing accessible to everyone.

3. D-Touch Pen

This technology is one of my favorite, it involves two separate technology, the first one is the print technology which is invisible to the naked eye, which can be used to send data or instruction to another device such as the D-Touch Pen, which reads the fine print on the paper and sends the data into a device which in turns provide information on what the location in the paper are. This is a very interesting discovery, where in a new breed of input device has been developed which makes use of paper or other tangible things a new set of computer per say.

Bookmark This!

del.icio.us Digg Google StumbleUpon Technorati

PHP (mutiple select) and checkbox Problem

Scenario:

You are coding a HTML form with the following form elements:
- checkbox
- mutiple select

Normally you would name the [checkbox] a “name” for all instances example:

<input type="checkbox" name="btype" value="a"> Type A
<input type="checkbox" name="btype" value="b"> Type B
<input type="checkbox" name="btype" value="o"> Type O
<input type="checkbox" name="btype" value="ab"> Type AB

For your [mutiple select] you just add “mutiple” on the select tag to make the dropdown element select mutiple items defined on the options tag.

Problem:

When submitting a group of checkboxes with the same name and a mutiple select, values passed on POST is the last item selected. For example, if you selected all checkbox named [btype] you are expecting the values (a,b,o,ab) will be returned as a string. But the problem is on PHP only value (ab) is returned.

In PHP POST and GET variables are treated differently, in order to retrieve all selected checkboxes and select option, you need to name your form elements with a “[]” (bracket) after the name, implying that the element will contain array values. In PHP you can define form elements as array values by adding “[]”, you can also explicitly define key names for array like for example:

Name:  <input type="text" name="personal[name]">
Email:   <input type="text" name="personal[email]">

By doing that you can access that values on PHP by:

foreach($personal as $key => $value) {
   print "$key => $value<br>";
}

One more problem that you might encounter is when using javascript to handle checkboxes and mutiple select, one classic example is for checkbox if you want to add a “Check All” button which selects all checkboxes, remember that you had named the checkboxes “btype[]” in order to define that variable as array, thus retrieving all selected checkboxes on PHP end. But how in the world can you access that name on javascript. Since javascript is also using “[]” to define array the best possible way to access form elements named with “[]” brackets are using:

...
document.forms[0].elements['btype[]'];
...

Summary:

When working on multiple select and checkboxes in PHP name this elements with “[]” to instruct PHP to store the values on array example:

<input type="checkbox" name="btype[]" value="a"> Type A
<input type="checkbox" name="btype[]" value="b"> Type B
<input type="checkbox" name="btype[]" value="o"> Type O
<input type="checkbox" name="btype[]" value="ab"> Type AB

<select name="season[]" multiple>
	<option value="spring">Spring</option>
	<option value="summer">Summer</option>
	<option value="autumn">Autumn</option>
	<option value="spring">Winter</option>
</select>

You can access it on PHP as regular arrays, note that in PHP 3, the array form variable usage is limited to single-dimensional arrays. As of PHP 4, no such restriction applies. Accessing named form elements with “[]” on javascript using this code:

...
document.forms[0].elements['btype[]'];
...

Bookmark This!

del.icio.us Digg Google StumbleUpon Technorati


Filipino Programmer | Philippines
The views expressed here reflect the views of the author alone.
HOME SUBSCRIBE WORK EXPERIENCE ABOUT ME



Filipino Programmer | Philippines © 2007 All Rights Reserved. Using WordPress Engine
Entries (RSS) and Comments (RSS).

Creative Commons License