0

can you run a query just by a button

e.g UPDATE DATABASE

when click the button have a query in it to automatically update a table in the database

6
Contributors
13
Replies
14
Views
7 Years
Discussion Span
Last Post by caro88
Featured Replies
  • [QUOTE=qazplm114477;1199233] [URL="http://jquery.com/"]http://jquery.com/[/URL] download and include in your php file[/QUOTE] I would disagree with that, I would always suggest using a CDN one, such as the one on google code ([url]http://code.google.com/apis/ajaxlibs/documentation/#jquery[/url]) [url=http://encosia.com/2008/12/10/3-reasons-why-you-should-let-google-host-jquery-for-you/]This article[/url] sums up my reasoning for this quite well. Read More

0

so

button is on a php file

Query is

SELECT loan WHERE bookid =$bookid
UPDATE loan.loan 'no'

but how do i set this in the button without opening another page?

0

Nice link. Wise to get the low down on the ajax object. After getting thoroughly confused by the thing and creating apps that didn't work, I turned to Prototype, which deals with Ajax calls extremely well. I've since migrated to jQuery.

0

But can i not just put it in a button in the php and use mysql query??

0

No, php is done once it leaves the server and the info is sent to the client (your browser). The user can interact with the page in 2 main ways: via javascript - the page can be changed without refresh (e.g. hiding or changing info on the page) - BUT no changes will occur on the server (db/files etc). Via page navigation (url or form submission). This is where php can do its stuff - this is where changes can be made to DB/files etc.

Ajax is a special case where a js script is run which can access a php script and change stuff on the server without the page having to be reloaded/re-accessed. It's not as simple as js trying to run a php script.

Sorry if it sounds confusing. 'Twas a heavy day yesterday!

0

ok i understand, i got it sorted thanks..took a while but got there :)

could you help with validation?

I have a form with the following:

enter book id : it a combo box of all book ids in the book table
Enter book name: combo box with all book names
book author: combo box with all book author

Could you tell me how as soon as the book id is selected into the form, the book name and author would authomatically appear that match that book id??

Hope im explaining this ok...If you could help it would be great! :)

0

This would be another AJAX routine. Get the value of the bookId selection then query the database to get the appropriate selection numbers to activate in the other boxes.

0

so set a query that takes the book name and book author that is entered in2 the bookid...totally confused in how i would do that??

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.