Bojak Posted May 5, 2014 Share Posted May 5, 2014 <!DOCTYPE html> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"> </script> <script language="javascript"> function toggle() { var element = document.getElementById("textMessage"); var text = document.getElementById("textSwitch"); if(element.style.display == "block") { element.style.display = "none"; text.innerHTML = "show"; } else { element.style.display = "block"; text.innerHTML = "hide"; } } </script> </script> </head> <body> <? $commentMessage = "this would be a test"; $x=1; while ($row = mysql_query($commentMessage) > $x) { echo '<a id="textSwitch" href="javascript:toggle();">show</a>'; echo '<div id="textMessage">' . $commentMessage . '<textarea></textarea></div>'; $x++; } ?> </body> </html> i want this to eventually connect to a database and loop through all the messages but for now i hard coded a message but it isnt working as i had hoped. its posting parts of the script instead of doing an echo. i attached a photo to explain more. if you could explain the issue i would be so thankful. Quote Link to comment Share on other sites More sharing options...
Bojak Posted May 5, 2014 Author Share Posted May 5, 2014 well it seems the issue was the beginning php tag but now its completely blank. Quote Link to comment Share on other sites More sharing options...
Bojak Posted May 5, 2014 Author Share Posted May 5, 2014 i fixed the issue.. it was blank because there was nothing in the database but i wasnt connecting it to a database just yet. next step is to connect to a database and loop it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.