Hi all.
Please help. How is it possible to transfer a variable from PHP to JavaScript.
I have the following code.

<?php
$id = 5;
?>
<script>window.location.href = 'view_topic.php?id=VAR'</script>

Instead of VAR should come the value of $id from PHP.

Thanks in advance.

I have just found the answer. The following code is working:

<script>window.location.href = 'view_topic.php?id=<?php print($id)?>'</script>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.