benji_182 Posted July 21, 2009 Share Posted July 21, 2009 Whilst I'm reasonably good at PHP I get stumped from time to time on the correct syntax when dealing with HTML and PHP. I'm working on this bit of code to create a basic content management system and fallen at one of the first hurdles. When trying to echo out the information from the DB into a loop I can't quite get the syntax right. Tried numerous methods but won't seem to work. Your help would be most appreciated! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <? include ("conninfo.php"); $query="SELECT * FROM cpaa"; $result=mysql_query($query)or die("Query Broken"); ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <h1>Edit Standards</h1> <form action="confirmedit.php" name="edit"> <input type="<? while($r=mysql_fetch_array($result)) { echo "<input type="text" name="test1" value="/$r["cpasubname"]/"/>"; } ?> </form> </body> </html> Sorry for such a basic problem. benji Link to comment https://forums.phpfreaks.com/topic/166791-syntax-problems/ Share on other sites More sharing options...
smerny Posted July 21, 2009 Share Posted July 21, 2009 echo "<input type="text" name="test1" value="/$r["cpasubname"]/"/>"; you have quotes within your quotes... either change the inner quotes to single quotes like 'text' or use backslashes before them like /"text/" Link to comment https://forums.phpfreaks.com/topic/166791-syntax-problems/#findComment-879504 Share on other sites More sharing options...
rhodesa Posted July 21, 2009 Share Posted July 21, 2009 actually, to print the value of an array item you need to put braces around it to: echo "<input type=\"text\" name=\"test1\" value=\"{$r['cpasubname']}\">"; Link to comment https://forums.phpfreaks.com/topic/166791-syntax-problems/#findComment-879507 Share on other sites More sharing options...
benji_182 Posted July 22, 2009 Author Share Posted July 22, 2009 YOU......ARE MY Best friend ever! Link to comment https://forums.phpfreaks.com/topic/166791-syntax-problems/#findComment-880198 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.