Run php code without refresh page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lepass_7
Forum Newbie
Posts: 7
Joined: Wed Apr 02, 2008 5:15 am

Run php code without refresh page

Post by lepass_7 »

Hey guys,
Does anyone knows how to run a php script without reloading the entire page again and again?
For example the layout of my page is something like this:
**************************************
* Header(menu, images, etc)
*
* phpscript
* {
* echo rand(0,10);
* }
*
* footer(images, text, etc)
*
************************************

So when i click on button(in the page) the page reloads and a random number apears, but every time i reload the page i want only the php script to be executed and the header and footer not to be reloaded again!!


Any ideas(thnxs in advance)?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Run php code without refresh page

Post by califdon »

That's exactly what "AJAX" does. It is Javascript that calls a PHP script that returns data without an HTML header, allowing the Javascript to wait for the data to arrive, then do whatever is desired, without reloading the page. Just google AJAX and PHP.
lepass_7
Forum Newbie
Posts: 7
Joined: Wed Apr 02, 2008 5:15 am

Re: Run php code without refresh page

Post by lepass_7 »

Thnxs!!!
Post Reply