0

I'm calling viewlog.php which display the xx rows of log table in a frame The viewlog.php SQl call work.
no issue initializing the $_SESSION I'm trying to add a next and prev button using a function that increase or decreased $_SESSION['offset']

<input type="button" value=" < PREV " onclick="PIframe();"> 
<input type="button" value = " NEXT >" onclick="NIframe();">
<iframe src="viewlog.php?os=<?php echo $_SESSION['offset']."&osl=" . $_SESSION['limit'];?>" name="LogIframe" id="LogIframe" />
</iframe

I'm 100% sure the Viewlog.php is getting the value of &_SESSION['offset']

My problem is

  1. I'm not sure if the function are being executed
  2. I'm not sure if the $_SESSION['offset'] is being updated
  3. I don't think document.getElementById is being run

    <?php
    function NIframe() {
        $_SESSION['offset'] = $_SESSION['offset'] + $_SESSION['limit'];     
        document.getElementById('LogIframe').contentWindow.location.reload();
    }
    
    function PIframe() {
        $_SESSION['offset'] = $_SESSION['offset'] - $_SESSION['limit'];     
        document.getElementById('LogIframe').contentWindow.location.reload();
    }
    ?>
    

I tried converting the Function to Javascript. The reload works but the $_SESSION is not being updated

<script type="text/javascript">    
function NIframe() {
<?php 
  $_SESSION['offset'] = $_SESSION['offset'] + $_SESSION['setofLimit'];
?> 
    document.getElementById('LogIframe').contentWindow.location.reload();
}
</script>

Help

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
rsarceno
  • 9
  • 1
  • The PHP code in your `NIframe()`-function will _always_ be executed since PHP get's executed on the server, before anything is send to the browser where your browser executes the JS. – M. Eriksson Mar 10 '18 at 20:05
  • 1
    Possible duplicate of [What is the difference between client-side and server-side programming?](https://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server-side-programming) – M. Eriksson Mar 10 '18 at 20:08
  • 1
    `document.getElementById` is never executed by PHP – Nico Haase Mar 10 '18 at 20:13

0 Answers0