Help in PHP Mysql script

Status
Not open for further replies.

bukaida

In the zone
I have a table containing name and address in mysql.I have a form in php which has a textbox where the user can enter the name and clicking the button gets the corresponding address from mysql database.Now I want to modify the script so that when the user is typing the name, the corresponding list of names starting with the letter the user has typed so far should appear in the textbox as a list of alternatives from the database from where the user can choose the name without typing further(Something similar to the phonebook of our mobile phones and something which the browser automaticaly does for the textbox by showing the previous inputs from the cache.).To be more exact, the script is similar to the script running in the search->advance search->search by auther name in the digit forum.No ,I am not asking the phpbb script for the advance search but the idea to design such script. Please help.
 

rocket357

Security freak
I would imagine that would require a decent amount of AJAX to accomplish. You could write a function in Javascript that handles retrieving the list of names from the server and call it "onChange" for your textbox. I'm not terribly versed in AJAX (my company just started really using it and I'm on the support programming team handling our previous version), so I can't be of much assistance with actual code...but AJAX should get you started in the right direction.

The same functionality might also be available in later versions of PHP (again, previous version of our software is still using PHP 4.4.x).
 
OP
bukaida

bukaida

In the zone
@rocket357-- Since the things are happening at the client end, javascript/other client side script has to be used and the event can be based on key press or focus. These informations are already known to me.I was mainly asking about the informations on the integration of the php, javascript and the database for the problem mentioned by me.
The same functionality might also be available in later versions of PHP

Php is a serverside scripting and cannot be used alone to perform the mentioned task, whatever may be the updated version, it cannot violate the basic concept of serverside scripting. Anyway thanks for reply.
 

rocket357

Security freak
Don't ask for help then insult my intelligence when I offer assistance. When I said later PHP versions might have this functionality, I was speaking strictly in terms of the integration you asked about. I'm well aware that PHP is server-side. Sorry if I didn't make that crystal-clear.

If you're aware of Javascript client-side scripting, then what more do you need to know? Perhaps I've misunderstood the question, but it appears to me that you asked how one would go about retrieving a list of names to display for the user to choose from...please correct me if I'm wrong.
 
OP
bukaida

bukaida

In the zone
@rocket357-First of all I am extremely sorry if by any means I have ofended you. There was no such intention for a person who is trying to help me.I tried to explain the problem in greater detail and the doubts arised from your reply.
Sorry again if it hurted you unknowingly.

Now my main doubt was that to access the database I am using a server side scripting and on the html page, a client side scripting.I donot have any idea, if it is possible to access the database with clientside scripting.If that is possible, it will solve my problem.
 

ahref

In the zone
Now my main doubt was that to access the database I am using a server side scripting and on the html page, a client side scripting.I donot have any idea, if it is possible to access the database with clientside scripting.If that is possible, it will solve my problem.
This is what AJAX is, I think.
 

rocket357

Security freak
bukaida said:
@rocket357-First of all I am extremely sorry if by any means I have ofended you. There was no such intention for a person who is trying to help me.I tried to explain the problem in greater detail and the doubts arised from your reply.
Sorry again if it hurted you unknowingly.
Nah, I should apologise...I did take your post somewhat offensively, but my reaction was more tied to the bad day I was having at work...forgive me for snapping back. I'm usually MUCH more level headed!

bukaida said:
Now my main doubt was that to access the database I am using a server side scripting and on the html page, a client side scripting.I donot have any idea, if it is possible to access the database with clientside scripting.If that is possible, it will solve my problem.
I've never *personally* done this, but it's my understanding that you can code a service for your web server that the AJAX code can connect back to. The service can then perform the database lookups you require. Since you aren't going through the "normal" channels (the http service), you don't need to refresh the page and can perform realtime lookups like you're asking about.

And I bet if you google AJAX you'll find open source / free services (GWT, if you're into Java) that are ready to roll out to your server as an AJAX-compatible service. AJAX uses XML (Asynchronous Javascript And XML), so there's quite a bit of freedom in structuring requests/responses as you need.

Good luck on the coding, and again, I apologise for my reaction in my last post.
 
Status
Not open for further replies.
Top Bottom