473,396 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Javascript and mysql

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
3 1145
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ronan | last post by:
Hi, I have a problem with a form using the PHP PEAR HTML_QuickForm package & javascript: I want to record the content of my form into a mySQL database then execute a javascript function. ...
2
by: RootShell | last post by:
Hello First of all i know that PHP is a server side, and JavaScript is a Client side programming language, but i need to know if there is any way i can add the variable "countDownInterval" from...
1
by: mike | last post by:
I'm fairly green with javascript, and have been looking everywhere for an example of how to load data from a mysql db into javascript arrays. For a little background on what I'm trying to do, any...
0
by: idealfellow | last post by:
Hi Guys, I have multiple Mysql DB instances containing same schema but different data in the tables, running in my unix server. I always have the issue of not upgrading...
1
by: Van Dugall | last post by:
Hello I have been writing a game in javascript which works fine but I wanted to step it up and request the data of the game from the server. I haven't really used php...all I know is from the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.