tags:

views:

166

answers:

5

I was wondering if there is a way to use php to return the values from a search without having to reload the whole webpage or using iframes or anything like that. I've tried searching for it but I always end up with AJAX and I was wondering if there is a PHP way for it...

+1  A: 

AJAX is what you're looking for. It means using JavaScript (on the browser) to initiate a request to the server (which may be running PHP, or any other language).

JW
+3  A: 

I suggest you read up on AJAX and what it is, as it is exactly what you are describing.

What AJAX is generating a request on the browser with javascript, sending the request to a server, generating content with whatever technology you want (be it PHP, .NET, etc.) and returning it to the browser, without the page ever 'reloading'. That's all it is, and that's what you want.

I recommend you check out something like jQuery as it is far away the most popular javascript library. It makes doing AJAX requests a piece of cake.

Paolo Bergantino
+1  A: 

PHP is a server-side technology, and what you describe is mostly a client-side issue.

Every technology that does what you want is going to be very close to Ajax, so I suggest to just take a little time and get yourself going with Ajax. There are plenty of javascript frameworks around that make life easier for you as an Ajax programmer.

Wouter van Nifterick
+1  A: 

PHP is server-side. It can't do anything unless a web request is made (i.e. the user clicks on a link, requesting a page). This is why AJAX exists. The javascript on the client side is able to initiate a web request in the background and decide what to do with the response.

Check out jQuery. It makes AJAX a snap:

http://docs.jquery.com/Ajax

Andrew
Why the down-vote when I have the exact same answer as the highest scored answer (and a more direct link)?
Andrew
I suspect someone that is against AJAX and/or jQuery voted you down, as everyone got a downvote but Simon.
Paolo Bergantino
My thanks to those who voted me back up.
Andrew
A: 

Forgive me for being contrary, but if Ajax is the answer, then we're asking the wrong question.

It's time developers grew out of Ajax, just like we grew out of animated GIFs, DHTML and Flash websites.

12345