Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could try constructing the javascript with PHP. this will allow you to load executable content instead of static. To do this, first you'll nee a javascript function to load the php into a script element. something like :-</p> <pre><code>function loadscript(src){ var myscript = document.createElement('script'); myscript.src = src; document.getElementByTagName('head')[0].appendChild(src); } </code></pre> <p>you can then write php variables to a constructed JS code then load the php by calling the function in the browser. The PHP would be somthing like this.</p> <p>on the server myphpcode.php</p> <pre><code>&lt;?php $sessionid = $_SESSION['user_id']; ?&gt; mydiv.innerHTML = 'User ID ' + &lt;?php echo $sessionid; ?&gt;; </code></pre> <p>js call in HTML page</p> <pre><code>loadscript('myphpcode.php'); </code></pre> <p>use the same method to send data back to the server via PHP by constructing a valid query string in javascript to apppend to the loadscript call.</p> <pre><code>var a = 'some data'; var b = 'some more data'; var urlstring = 'myphpcode.php?a=' + a + '&amp;b=' + b; loadscript(urlstring); </code></pre> <p>you can then store the javascript variables in a database for example by writing a function in myphpcode.php.</p> <pre><code>&lt;?php include mydbconnection.php // some database connection code if ((isset $_GET["a"]) &amp;&amp; (isset $_GET["b"])) { //check the url query string has data $a = $_GET["a"]; $b = $_GET["b"]; $query = "INSERT into mydatabase.mytable (columnA, columnB) VALUES ('" . $a . "','" . $b . "');"; if ($mysqli-&gt;prepare($query)){ $mysqli-&gt;execute(); } } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload