I'd like to write a javascript code that shows a text included in php variable. This php variable has been taken from a mysql database.
PHP Code:
<?php
// conect to the database
include("config.php");
// Download words
$video_number = "4";
$data = mysql_query ("SET NAMES 'utf8'");
$data = mysql_query("SELECT cz FROM videos WHERE id='$video_number' ") or die(mysql_error());
$info = mysql_fetch_array($data);
$words_unedited = $info['cz'];
?>
Code:
<p><button onclick="myFunction()">Show the text</button></p>
<script>
function myFunction()
{
var unedited_text = '<?php echo "$words_unedited" ;?>';
document.write(unedited_text);
}
</script>
For some reason the javascript code is not printing anything
May you please help me?