You wouldn't want to do it in PHP, because PHP runs on the server and wouldn't know if anyone had clicked anything until it was asked to deliver a new page, and I suspect you don't want to reload the entire page just so that you can change the colour of a table cell. You can't do it in HTML because HTML isn't a programming language and so can't do anything.
You could do it in Javascript: give the relevant <td> element an id attribute, and then Javascript can locate the cell with getElementById('whateveryoucalledit');