Javascript can link to mysql?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wish
    New Member
    • May 2007
    • 65

    #1

    Javascript can link to mysql?

    <head>
    <script type="text/javascript">
    function delete_confirm( )
    {
    var r=confirm("Are you sure you want to delete this record?")
    if (r==true)
    {
    <!--start to link to mysql to delete the particular record-->
    }
    }
    </script>
    </head>

    my question is how to connect to mysql using the javascript if the user press button ok or true to comfirm he/she want to delete the record?

    if i open the php tag in between like this

    if (r==true)
    {
    <?
    mysql_connect(" localhost","stu dent","123") or die (mysql_error()) ;
    ...
    ?>
    }
    it is look like cant work after i tested..

    Someone can guide me to complete my confuse...
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    did u hear the term AJAX.
    it is the soultion of ur Q.
    mind it in JS it is not valid to connect with DataBase directly.
    in AJAX u can make client fool that ur page accessing DataBase through JS.

    kind regards.
    dmjpro.

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by wish
      <head>
      <script type="text/javascript">
      function delete_confirm( )
      {
      var r=confirm("Are you sure you want to delete this record?")
      if (r==true)
      {
      <!--start to link to mysql to delete the particular record-->
      }
      }
      </script>
      </head>

      my question is how to connect to mysql using the javascript if the user press button ok or true to comfirm he/she want to delete the record?

      if i open the php tag in between like this

      if (r==true)
      {
      <?
      mysql_connect(" localhost","stu dent","123") or die (mysql_error()) ;
      ...
      ?>
      }
      it is look like cant work after i tested..

      Someone can guide me to complete my confuse...
      Javascript is client side and does not connect to databases. You need a server side language to do that. You may use ajax to call the server side script that connects to the database.

      Comment

      • wish
        New Member
        • May 2007
        • 65

        #4
        i never heard AJAX before...and i also dun know how to use it.

        can u guide me?

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Originally posted by wish
          i never heard AJAX before...and i also dun know how to use it.

          can u guide me?
          See the tutorials in the Offsite Links thread.

          Comment

          Working...