Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As the comments have suggested AJAX is your answer. </p> <p>With <a href="http://api.jquery.com/jQuery.ajax/" rel="nofollow">jQuery an ajax call</a> would look something like this:</p> <pre><code>$(document).ready(function() { setInterval(function(){ $.ajax({ url: "timeupdate.php", type: "GET", dataType: "html", success: function(html) { $("#date_registered_element").html(html); } });//end ajax call },1000);//end setInterval });//end docReady </code></pre> <p>This will output the text returned from timeupdate.php to a div with the id of "date_registered_element" -> change this to the name of the div to which you wish to output the updated text.</p> <p>In order to pass a session variable to the Ajax function you need to have the server echo out the Session variable before the script runs (i.e. as the page is rendered) something like this: HTML:</p> <pre><code>&lt;div id="user_date" style="display: none;"&gt; &lt;?php echo $_SESSION["User_Date"]; ?&gt; &lt;/div&gt; </code></pre> <p><strong>Please NOTE:</strong> You need to be very careful with this. Anyone who looks at your markup in a browsers View Source or Developer Tools will be able to see the SESSION Variable echod out. You should only do this if the data represents no security risk. In my opinion you would be better passing no GET variables in the Ajax call and just referencing the SESSION variable in the timeupdate.php script. The point of SESSION variables is to provide state-like functionality to HTTP so you should never need to send SESSION variables over a HTTP request. </p> <p>That said, if you wish to do it the way you currently have it set up then the code is below. </p> <p>Once you have echoed out the SESSION variable onto the page, you can then collect the value from the id with jQuery and pass it to the Ajax function:</p> <p>Javascript/jQuery:</p> <pre><code>var url = "timeupdate.php?time=" + $("#user_date").text(); //pass the url to the Ajax function in the ajax function like this: $.ajax({ url: url, //the rest of your ajax function here }); </code></pre> <p>if you add jQuery to your page <code>&lt;head&gt;&lt;/head&gt;</code> tag <strong>BEFORE</strong> your existing script this should work:</p> <pre><code>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"&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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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