Can someone please help. I have a rollover image and when you click it takes you to a page. But I want it to remain on the same page. I want it to display data from a db. But should appear on the same page where the button is. So on click I want it display the echo in my function. Not on body load but only on the click event. I tried using a session but when the page loads it still appears. my code kinda looks like this. "onClick="<? test(); ?>" " inside that a href of the rollover please help :(

8 Years
Discussion Span
Last Post by Menster

Hi there,

The problem is that php is pre-processed, ie all of the php code is run before a page is served to the client and therefore, you cannot add interactivity to a page (like with the onXXXX event handlers of html elements) with php. You need to use a client side scripting language like Javascript. If you really need to use server side stuff to do the job, then you'll have to use AJAX to handle the request.


Well, not really. You need to handle the intitial request (the client clicking on the button/link) with a javascript or other client side scripting language. You can not call a php function directly from that event, if you need to run a php function, you'll need to write an AJAX function (which is javascript, but in a unique methodology) to request that function be run by the server.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.