Javascript to access mysql db?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mosher

    #1

    Javascript to access mysql db?

    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



  • bruce_brodinsky@glic.com

    #2
    Re: Javascript to access mysql db?

    Using Microsoft technology, you'd code:

    var oCn=new ActiveX("ADODB. Connection")
    oCn=sYourConnec tionString
    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.

    Comment

    • bruce_brodinsky@glic.com

      #3
      Re: Javascript to access mysql db?

      Sorry, a slight inaccuracy in my previous post (the memory is gone)

      oCn=new ActiveXObject(" ADODB.CONNECTIO N")

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

      Comment

      • kaeli

        #4
        Re: Javascript to access mysql db?

        In article <y6GdnUN9s6VTKa XfRVn-sw@comcast.com> , mosh_king2000@y ahoo.com
        enlightened us with...[color=blue]
        > 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?
        >[/color]

        Client-side Javascript cannot by itself talk to a server-side database. It
        needs help.
        [color=blue]
        > Some things to consider: when someone types in multiple characters, the
        > database needs to be accessed everytime for each character.[/color]

        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. :)
        [color=blue]
        >
        > And it if cannot be done in javascript, can it be done in any other
        > language?[/color]

        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?



        Comment

        Working...