Php "onclick" run function and update anyone?

As i understand wanting to do this in php is inherently silly, but i still want it to work.

i have a php function that i want to run and then update on the current page when the user clicks on an image or button. that’s my currrent road block, although there’s probably a better overall solution to my problem which is:

to automatically update a “current” file every 24 hours and then allow the user to browse foward and back through files accordingly.

right now this is how i have it working:

http://michelleip.com/styxville/index.php

$file_array = array
(‘http://www.michelleip.com/01.jpg’,
http://www.michelleip.com/02.jpg’,
http://www.michelleip.com/03.jpg’,
http://www.michelleip.com/04.jpg’,
http://www.michelleip.com/05.jpg’,
http://www.michelleip.com/06.jpg’,
http://www.michelleip.com/07.jpg’,
http://www.michelleip.com/08.jpg’,
http://www.michelleip.com/09.jpg’,
http://www.michelleip.com/10.jpg’,
<!–etc…–>

$currentday = date(“j”);

$currentfile = “$file_array[$currentday]”;

print ("<IMG SRC=$currentfile>");

<!-- this is the part that i really need help with, i want the back(yesterday) and forward(tomorrow) arrows to run a php function that basically just says “display ++$currentfile or --$currentfile” and updates the current page, but also as users click back or forward repeatedly…–>
//////

print ("<a onlclick= href="??yesterday"><IMG SRC=“yesterday.jpg”></a>");

print ("<a onlclick= href="??tomorrow"><IMG SRC=“tomorrow.jpg”></a>");

i realize this could be a client side solution, but i’ve been doing everything in php and thought it would offer the cleanest solution, though i suspect i might need a little javascript. any illumination is greatly appreciated. thanks!