paulsinclair Posted June 12, 2008 Share Posted June 12, 2008 I am only new to PHP and MYSQL but have used SQL before. I am trying to build a process that will default a form to the current contents of a row, and then allow the user to modify the data and resave it. Everything is going fine, except that the Description is only populating the first word of the description to the form. I am guessing it is something simple, but I can't figure it out. Thanks for any help you can give me. <HTML> <HEAD> <TITLE>New Document</TITLE> </HEAD> <BODY> <? if($_REQUEST['action']=="edit") { $result=mysql_query("SELECT `MaterialsID`,`CODE`,`Description`,`buyprice`,`buildprice`,`buyunit`,`buildunit`, supplierid FROM `materials` WHERE materialsid={$_REQUEST['materialsid']};"); $i=0; while( $row=mysql_fetch_array($result) ) { echo "<form action=list_materials.php method=get>"; echo "<table border=0 cellpadding=0 cellspacing=0 align=center>"; echo "<tr><td></td><td></td></tr>"; echo "<tr><td></td><td><input type=hidden size=20 name=MaterialsID value=".$row['MaterialsID']." ></td></tr>"; echo "<tr><td><b>CODE:</b></td><td><input type=text size=20 name=CODE value=".$row['CODE']." ></td></tr>"; //The next line is only putting the first word of the description in the input field. echo "<tr><td><b>Description: </b></td><td> <input type=text size=50 name=description value=".$row['Description']." ></td></tr>"; echo "<tr><td><b>Buy Price:</b></td><td> <input align=right type=text size=20 name=buyprice value=".$row['buyprice']." ></td></tr>"; echo "<tr><td><b>Buy Unit:</b></td><td> <input type=text size=20 name=buyunit value=".$row['buyunit']." ></td></tr>"; echo "<tr><td><b>Build Price:</b></td><td> <input type=text size=20 name=buildprice value=".$row['buildprice']." ></td></tr>"; echo "<tr><td><b>Build Unit:</b></td><td> <input type=text size=20 name=buildunit value=".$row['buildunit']." ></td></tr>"; echo "<tr><td><b>Supplier #:</b></td><td> <input type=text size=20 name=supplierid value=".$row['supplierid']." ></td><td></td></tr>"; echo "<tr><td></td><td><input type=submit border=0 value=\"Submit\"></td></tr>"; echo "</table>"; echo "</form>"; } } ?> </BODY> </HTML> Link to comment https://forums.phpfreaks.com/topic/109836-solved-prepopulating-a-form-from-the-results-of-an-sql-query/ Share on other sites More sharing options...
corbin Posted June 12, 2008 Share Posted June 12, 2008 Right now it will look like: value=blah blah blah You need quotes. value="blah blah blah" So... echo "<tr><td><b>Description: </b></td><td> <input type=text size=50 name=description value=\"".$row['Description']."\" ></td></tr>"; Link to comment https://forums.phpfreaks.com/topic/109836-solved-prepopulating-a-form-from-the-results-of-an-sql-query/#findComment-563655 Share on other sites More sharing options...
paulsinclair Posted June 12, 2008 Author Share Posted June 12, 2008 Yep. That did it. Should have thought of that. That was the source of my last problem too. Thanks for the quick response. Link to comment https://forums.phpfreaks.com/topic/109836-solved-prepopulating-a-form-from-the-results-of-an-sql-query/#findComment-563658 Share on other sites More sharing options...
corbin Posted June 12, 2008 Share Posted June 12, 2008 No problem ;p. You should always use quotes in HTML tags (maybe unless it's numbers...). (as in var="val") Link to comment https://forums.phpfreaks.com/topic/109836-solved-prepopulating-a-form-from-the-results-of-an-sql-query/#findComment-563659 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.