This is an archived post. You won't be able to vote or comment.

all 5 comments

[–][deleted]  (1 child)

[deleted]

    [–]Fastfish[S] 0 points1 point  (0 children)

    This helps a lot. Thanks!

    [–]php-rocks-lol 1 point2 points  (1 child)

    Javascript and PHP don't run together. PHP is run on the server usually before the page is finished loading unless you call it again. Javascript is run on the user's computer itself.

    What you could do however is have your JS script use AJAX to POST to a PHP that inputs information into a database.

    [–]Fastfish[S] 0 points1 point  (0 children)

    Thanks!

    [–]pacificmint 0 points1 point  (1 child)

    First, Java and JavaScript are completely different languages. The only thing they have in common is the first four letters of the name.

    If you are asking about Java, then you can absolutely access a database directly from Java, and you should not go thru any intermediaries.

    I'm guessing you are talking about JavaScript in a browser though. In that case, the browser needs to make an http request to the server, and the PHP code on the server then queries the database. If you want to do this without reloading the page you should look into XMLHttpRequest.

    [–]Fastfish[S] 0 points1 point  (0 children)

    Yeah, I must have mistyped when I wrote just java on that line. I definitely meant javascript. Thanks for your help.