View Single Post
Old 01-14-2013, 02:52 PM   PM User | #1
cast_no_shadow
New Coder

 
Join Date: Aug 2012
Posts: 44
Thanks: 26
Thanked 0 Times in 0 Posts
cast_no_shadow is an unknown quantity at this point
show a text from php variable

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?

Last edited by cast_no_shadow; 01-15-2013 at 10:00 AM..
cast_no_shadow is offline   Reply With Quote