https://coursesweb.net/php-mysql/website ... ss-data_s2
From my mebers page Users.php i don`t get an title from database.
I added simple an <title>, and i`m very supriced i cant add php code into <title>.
in this code it does not show value of $users['name'].
i tried also echo php also not working:
Code: Select all
<?php
include('../connection.php');
$id = (int) $_GET['id'];
$sql=mysqli_query($conn,"SELECT * FROM `user` WHERE id='" . $id . "' ");
$users=mysqli_fetch_assoc($sql);
?>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<title>Profile View '. $users['name'] .'</title>
<script>
function myFunction() {
var x = document.getElementsByTagName("TITLE")[0].text;
document.getElementById("demo").innerHTML = x;
}
</script>