I'm certainly not a jquery.guru but do use jquery for database update
(php/mysql)
I think from your post your thinking of jquery in the same league as
server side languages like php & ruby and its not.
Its client side javascript with all the restrictions that brings but a
much nicer way of dealing with it.

Ashley's mention of understanding how you would do it using standard
forms is really good as you are essentially enhancing not replacing
that.
jquery will still send information in much the same way as a form
would though with the benefit of extracting page info from the DOM not
just in form fields, not refreshing the page and hiding a lot of the
background work.

so for a very simplified psuedocode example in a row you want to
update.
Use jquery to grab the data in the row with something like $
(this).parent('td').text

then put into a post call and use the callback to check the response
from the php script which does the work with the database update

 $.post("", { name: "data from row" },
   function(data){
     if(data == 'crapped out') {
      alert("Damn it the script " + data);
    } else {
     alert("Hey it worked, the database row is " + data);
    }
   });

In your_script_that_works_with_the_sql.php you would check the post
values and work with them exactly as you would with a standard form
then just echo out the response to the update which gets sent back as
the callback data.

eg.
if($result) {
$return = 'updated';
} else {
$return = 'crapped out';
}

exit($return);




On May 6, 8:57 am, John <[EMAIL PROTECTED]> wrote:
> I have the same question. I have over 20k rows of data in mysql, and
> the idea is for there to be an update button beside each row. I don't
> see any examples of how to interact with the database here -- in php
> it's $sql = "..."; in ruby/rails it's Thing.new[...], but what's up
> with jquery? I don't think an explanation would be voodoo - it'd be a
> lifesaver. I already understand the old ways - school me on the
> jquery.
> Thanks
> John
>
>
>
> > This is a pretty big question. What you need to do is learn how to do
> > it with regular HTTP interaction with the backend. Once you understand
> > that you'll be able to adapt it to Ajax. A firm grounding in HTTP
> > makes XHR pretty straightforward.
>
> > Doing this right is not simple. You should probably read up on REST
> > and understand which parts should GET and which parts should POST (or
> > really even PUT/DELETE but that's often unused due to bad support and
> > general lack of understanding).
>
> > The take away point is that if you don't know how to do every part
> > with regular forms and backend interaction already, doing it in Ajax
> >  will seem like insurmountable voodoo.

Reply via email to