How to change the php variable with the javascript button click without reloading the page


I have created a news area where i have display 3 thumbs of news at a time the source is from mysql database. i have used the query like this:

$eu = 0; $limit = 3; $query2=mysql_query("SELECT * FROM news ORDER BY ID DESC LIMIT $eu,$limit");

now i have also create two buttons with like this

i want to use this buttons for display the next 3 thumbs onclick and prev 3 thumbs. but not able to change the value inside the query i.e $eu.

how can i change the $eu value inside the mysql query with javascript or any other suggestion and also i dont want to do this with reload of page with passing query parameters. i want it without reloading of page

You'll need to do an ajax call, pass in the value for $eu (eg, 3, 6, 9 etc) that you need, and pass back the contents of the news feed, to replace the existing lot.

There are many ways you can do this and which is easiest depends on the frameworks you are using. Google is your friend here, there are plenty of tutorials etc.