By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,619 Members | 1,746 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,619 IT Pros & Developers. It's quick & easy.

Javascript and mysql

P: n/a
Hi

I have some pages which perform Javascript calculations etc. and end up
with a number in a box at the bottom of a page. The pages themselves are
PHP, but with Javascripts embedded in them.

How can I get the results of these calculations (which are in text
boxes), and place them into a mysql database?I gather that it may not be
possible to do this directly, but is there any way around it? I dont
want to have to rewrite the scripts in another language!

Cheers

Chris
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Javascript in this context is for client side scripting only. MySQL is
a server side process. You are going to have to use a server side
script, in your case the obvious candidate being PHP, to put the form
data into the database. Make the form's action attribute a PHP script
(if it isn't already). There are a zillion tutorials on the web for
using PHP with MySQL. Good Luck.

Jul 23 '05 #2

P: n/a
In article <d1**********@heffalump.dur.ac.uk>, c.********@durham.ac.uk
enlightened us with...
I have some pages which perform Javascript calculations etc. and end up
with a number in a box at the bottom of a page. The pages themselves are
PHP, but with Javascripts embedded in them.

How can I get the results of these calculations (which are in text
boxes), and place them into a mysql database?


If they're in text boxes, just submit the form to a PHP script that updates
the DB.
Client-side, stand-alone Javascript cannot directly "talk" to a MySQL
database. I'm sure somewhere someone's working on that. *heh*

--
--
~kaeli~
With her marriage, she got a new name and a dress.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #3

P: n/a
Chris Storey wrote:
Hi

I have some pages which perform Javascript calculations etc. and end up
with a number in a box at the bottom of a page. The pages themselves are
PHP, but with Javascripts embedded in them.

How can I get the results of these calculations (which are in text
boxes), and place them into a mysql database?I gather that it may not be
possible to do this directly, but is there any way around it?
$query="INSERT into TABLENAME (calculationField1,calculationField2 )
values('$result1','$result2')"
Where you have textboxes named "result1" and "result2".

When you submit the form, these values are available to the processing
page as :

$result1 or $_POST['result1'], depending on which version of PHP you
are using.

Mick

I dont want to have to rewrite the scripts in another language!

Cheers

Chris

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.