How can I increase a variable that is in php using javascript and that in turn with a button reload the page

0

I'm doing a program that extracts information from a database and I want it to be incremented by a counter that acts as an id in a SQL query when it is given in the "next" AND "previous" buttons.

$acum = 1;
$consulta = "SELECT * FROM noticia where Id = '$acum'";
    
asked by Nicolas 19.11.2017 в 19:03
source

1 answer

0

From what I understand you can not manipulate the php content from js, since the php code works with the server and js with the browser, but you could try to pass the incremented variable forwards js with a hidden input. To pass the variable to js and increase it you can do something kind:

 var acum = <?php echo $acum; ?>;
 <!-- después la convertís en int -->
 var acum2 = parseint(acum);

I hope you find it useful

    
answered by 19.11.2017 в 23:25