How to convert javascript variable into php variable? -
I am new to programming and am trying to create a program that will register a selected location in my database. I want to convert the js variable to $ phpvar php variable. Please click me
$ ('(b) (function () {var str = [], item; $ .each ($ (' # place li. '+ Settings SITSSS + 'A'), function (index, value) {items = $ (this) .attr ('title'); str.push (item);}); & lt ;? Include php "accounts / config.php "; $ Phpvar = '" + str + "' mysql_query (" Insert in sample values) ('$ Phpvar.' '')); // echo $ phpvar;; & gt;;})}) ; As the previous speaker has already been explained, you need to think in the context of client-side. Running code and server side row Code Whenever you want to share a state between those two parts of your application, you need some communication mechanism.
Client -> Server < / H2>
You need to make an HTTP request for this. This can be either a post or a AJAX call, only take a look for the latter because you are already using jQuery already.
$. Post ({"savesample.php", {myPostVar: str}}) done (done function () {warnings} VI ( "saved sample.");});
Of course you need a server side to handle this request:
Server -> Client
It's very easy you can definitely use AJAX again (get a request on your php file, which generates a good JavaScript-compliant output just like JSON).
Or just a Type inline-script-tag your variable:
Comments
Post a Comment