SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    updating a MySQL record using ajax

    What is the best way to update a specific record in MySQL using ajax? I have a record appear on a web page and I want to allow someone to update it. My greatest difficulty is how do I ensure that the id of the mysql record appearing on the page is the one that is updated. Basically, I want to sent the id to the webpage and have that id sent back using ajax to the php script so that the php script updates the correct record in the database. What I am thinking is that I should send the id, place it on the page and use something like getElementByID to get the ID, place the result in the onclick javascript function and send to the PHP script. Am I on the right track or better yet is there a simple way to do this perhaps using a framework?

    A thousand thanks to all those who reply,
    Steven.

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Right, you need a unique identifier for that record, whether it's the ID or some other field - output that to the browser like you said and onclick send that ID with the other fields to the server for updating. If you're using a form you could put the ID in as a hidden form element.


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
  •