Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    May 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation How to use Mysql Query inside Javascript functions?

    Hello Everybdy,

    I am trying to use Mysql Query inside a Javascript function, which also has php code. I am trying to use the on-click property of <a></a> tag, so as to call a javascript function, which is having an argument and this argument is being used by Mysql Query to check whether the table is empty, for that specific record.

    If anybdy knows, whats the solution, please tell me!!!
    Thanks in advance.

  • #2
    New Coder
    Join Date
    Oct 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    mysql is database stuff, hence, server side. javascript is ONLY client side scripting. You may not interact with the server in any way (directly). However, You could use AJAX calls to like a php file that will return if the table is empty or not. But all in all, you can't use javascript itself to interface with mysql

  • #3
    Regular Coder
    Join Date
    Feb 2005
    Posts
    525
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There is no way to do this outside of Ajax, of course you can always echo something in. Such as:

    <script>

    function doalert(){
    alert('<?php echo($var) ?>');
    }
    </script>
    Single Paradox
    My Site (Under construction)

    Not too bad for a 15 year old

  • #4
    New to the CF scene
    Join Date
    May 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thanks for the replies, I too searched an answer, but everywhere I got the same answer that I need AJAX. Thanx again, this forum is very helpful.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •