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 Link to comment https://forums.phpfreaks.com/topic/161400-solved-data-to-text-field/ 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]'>"; Link to comment https://forums.phpfreaks.com/topic/161400-solved-data-to-text-field/#findComment-851840 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. Link to comment https://forums.phpfreaks.com/topic/161400-solved-data-to-text-field/#findComment-851864 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. Link to comment https://forums.phpfreaks.com/topic/161400-solved-data-to-text-field/#findComment-851951 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.