Javascript and mysql

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris Storey

    #1

    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
  • Got Scripting?

    #2
    Re: Javascript and mysql

    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.

    Comment

    • kaeli

      #3
      Re: Javascript and mysql

      In article <d13uk7$st2$4@h effalump.dur.ac .uk>, c.p.storey@durh am.ac.uk
      enlightened us with...[color=blue]
      > 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?[/color]

      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.



      Comment

      • Mick White

        #4
        Re: Javascript and mysql

        Chris Storey wrote:
        [color=blue]
        > 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?[/color]

        $query="INSERT into TABLENAME (calculationFie ld1,calculation Field2 )
        values('$result 1','$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[color=blue]
        > want to have to rewrite the scripts in another language!
        >
        > Cheers
        >
        > Chris[/color]

        Comment

        Working...