[Solved] Append Javascript variable to a PHP variable [closed]


The problem here is the order that this page is parsed. The PHP will first render the page on the server and then send to the browser. The javascript is then executed on the client-side.

Think of it like this. Anything in-between the

echo $_SESSION['fname_" + countItem + "'] ;

I’m surprised this isn’t throwing an error?

What do you actually need to do (the bigger picture). It looks like you are looping and creating several elements. If this is the case you should use PHP to do all of this?

If not then maybe you can use AJAX to call a PHP page that will provide the values from the session.

1

solved Append Javascript variable to a PHP variable [closed]