That pretty much ensures that $clicked will always equal the string "Y".
I think this hasn't gotten responses because what you are trying to accomplish is confusing. I almost suspected that you were trying to mix client-side script with server-side script as if they were in the same context. In fact, on reread, I think this is exactly what you are attempting to do.
To pull this off, you would need to do a post-back to the web server. In other words, Capture the mouse click via JS and submit a POST or GET. My advice, keep it client-side. This is all possible with DHTML. In other words, PHP is not necessary here.