have a re-read of some of the php beginners stuff.
php is serverside scripting which sends plain text to the browser. As programmers we make sure that text is something the browser understands - HTML, XML etc. When the browser reads the HTML (mostly) it decides what client-side actions to take.
An onclick event is therefore client-side as it happens on the browser and is nothing to do with php. If you want php to do something you will need to submit a form, call a page etc and refresh the content of the screen.