manels1111 Posted June 8, 2009 Share Posted June 8, 2009 Hi everyone I'm fairly new to mysql and somewhat ok with php. Anyhow using 5.0.18 mysql. Here is problem which might be fairly simple but I can't figure it out. I'm pulling data from a table in mysql that for each row I create a text field and set the value to the value from the database. This is working except its only displaying the first word of the stored data. So "Half Court" is stored in the database and when my text field is filled with the value it only fills with "Half" Here is the layout. IDcat_idcategory 11Half Court 12Full Court 13Jump Stop Here is the php to pull the code <? $ID=$_REQUEST['ID']; ?> <form name="testform" method='POST' action='inputdrills.php'> <? require "config.php";// connection to database $result = mysql_query("SELECT * FROM category WHERE ID = '$ID'")or die(mysql_error()); while($row = mysql_fetch_array( $result )) { echo "<input type='text' name=$row[cat_id] value=$row[category]>"; } ?> <br> <input type="Submit" value="Save Drills"> </form> Everything works fine but I get three text fields created and everything but only the first word of the stored database information shows up in the text field. Am I missing something really simple? Thanks in advance Quote Link to comment Share on other sites More sharing options...
cunoodle2 Posted June 8, 2009 Share Posted June 8, 2009 Put single quotes around the field name. Html stops at the space as it thinks its the end of the statment.. echo "<input type='text' name='$row[cat_id]' value='$row[category]'>"; Quote Link to comment Share on other sites More sharing options...
manels1111 Posted June 8, 2009 Author Share Posted June 8, 2009 Thanks so much worked like a charm. Quote Link to comment Share on other sites More sharing options...
cunoodle2 Posted June 8, 2009 Share Posted June 8, 2009 Please mark this topic as solved so other people can pass by 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.