SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Nov 2000
    Posts
    740
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Updating mySQL db with javascript

    I have a list of todo items on a page, with a status combo box to the right of each one. If I choose a value in the combo box, I want the appropriate record in my mySQL database to be updated.

    How can I achieve that? I presume javascript is the best way to do this?

    Thanks,

    Jon

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,017
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    update db

    Javascript is client-side, so you need a way to get that information back to the server (AJAX, GET, POST) so that a server-side script can update the database.

  3. #3
    SitePoint Guru
    Join Date
    Nov 2000
    Posts
    740
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, perhaps the question I should have asked is, "How can I trigger some php code using javascript?"

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,017
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    update db

    You could have a form submit POST variables to the php file and have that update the database using the values. Or you can send them as GET vars like
    www.site.com/db_update.php?id=3&new_val=maricopa
    Or maybe the best way would be using AJAX. There's lots of tutorials online, but here's one to give you an idea http://www.webpasties.com/xmlHttpRequest/


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •