By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,776 Members | 1,400 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,776 IT Pros & Developers. It's quick & easy.

Javascript to access mysql db?

P: n/a
Hi all, I was wondering if there was any way that I can have a webpage with
a text field that acts as a search box and when someone types even one
character (letter or number) into the text field, it will access a mysql
database and show results for any field in the db that starts with that
letter. This is essentially an instantaneous database search script. Any
ideas?

Some things to consider: when someone types in multiple characters, the
database needs to be accessed everytime for each character. For example,
someone types into the text field very quickly the letters: "ted" The
javascript will search the database for any entries that start with "t",
then narrow it down to all entries that start with "te" then all entries
that start with "ted"...etc.

And it if cannot be done in javascript, can it be done in any other
language?

Thanks in advance,

Mosher

Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Using Microsoft technology, you'd code:

var oCn=new ActiveX("ADODB.Connection")
oCn=sYourConnectionString
oCn.open
var oRs=new ActiveX("ADODB.Recordset")
..... etc

The user will probably get "this is unsafe, press yes to continue"
message boxes here, but it will work.

Jul 23 '05 #2

P: n/a
Sorry, a slight inaccuracy in my previous post (the memory is gone)

oCn=new ActiveXObject("ADODB.CONNECTION")

Previously, I had posted simply "new ActiveX" instead, sorry

Jul 23 '05 #3

P: n/a
In article <y6********************@comcast.com>, mo***********@yahoo.com
enlightened us with...
Hi all, I was wondering if there was any way that I can have a webpage with
a text field that acts as a search box and when someone types even one
character (letter or number) into the text field, it will access a mysql
database and show results for any field in the db that starts with that
letter. This is essentially an instantaneous database search script. Any
ideas?

Client-side Javascript cannot by itself talk to a server-side database. It
needs help.
Some things to consider: when someone types in multiple characters, the
database needs to be accessed everytime for each character.
That's not a good idea in general.
Do you know how long that will take? For each DB query, a request has to go
to the server. Then the server has to run something that queries the DB. Then
the response has to go back to the client.
You'll need to optimize the hell out of the script, the DB, and your
connections big time.
Google manages it, so it CAN be done. In theory. :)

And it if cannot be done in javascript, can it be done in any other
language?


There was a thread around here about Google's adwords program (I think) that
was talking about how they used client-side javascript xmlhttp request to
talk to their server-side process that does something VERY similar to this.
Check the archives for the thread.

--
--
~kaeli~
If a parsley farmer is sued, can they garnish his wages?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.