00falcon Posted September 8, 2007 Share Posted September 8, 2007 Hi all... as you can gather from posting in this forum... i am very new to this... (PHP & MySQL) But what i have is a site... that displays what computers we have in stock and for sale... When stock items need to be changed... i tried to do an UPDATE by loading the current values into a form field as the initial values from the data in a MySQL table... So far... My Select, Insert, Delete and Update are all working... But when i load the page containing the form to be populated... it only loads the first word of the data... look like a space is getting in the way... But as i said... noobe... ------------------------------- Troubled Code <?php include('config.php'); $id=$_GET['id']; $query = "SELECT * FROM desktops WHERE id='$id'"; $result = mysql_query($query) or die(mysql_error()); while( $row = mysql_fetch_array($result)) { echo "<form id=desktops_update name=desktops_update action=desktops_update.php method=\"POST\">"; echo "<table width=800 border=0 cellspacing=0 cellpadding=0>"; echo "<tr>"; echo "<td width=378 rowspan=13 align=center valign=middle><strong>Quick Add Item </strong><br>"; echo "<img src=../images/Qadd-desktop.jpg width=200 height=161></td>"; echo "<tr>"; echo "<td><strong>ID:</strong></td>"; echo "<td><input name=id type=text id=id size=25 value=".$row[id]."></td>"; echo "</tr>"; echo "<td width=176><strong>Make:</strong></td>"; echo "<td width=246>"; echo "<input name=make type=text id=make size=25 value=".$row[make]."></td>"; echo "</tr>"; echo "<tr>"; echo "<td><strong>Model:</strong></td>"; echo "<td><input name=model type=text id=model size=25 value=".$row[model]."></td>"; echo "</tr>"; echo "<tr>"; echo "<td><strong>Code:</strong></td>"; echo "<td><input name=code type=text id=code size=25 value=".$row[code]."></td>"; echo "</tr>"; echo "<tr>"; echo "<td><strong>Proc:</strong></td>"; echo "<td><input name=proc type=text id=proc size=25 value=".$row[proc]."></td>"; echo "</tr>"; echo "<tr>"; echo "<td><strong>Ram:</strong></td>"; echo "<td><input name=ram type=text id=ram size=25 value=".$row[ram]."></td>"; echo "</tr>"; echo "<tr>"; echo "<td><strong>Hard Drive : </strong></td>"; echo "<td><input name=hdd type=text id=hdd size=25 value=".$row[hdd]."></td>"; echo "</tr>"; echo "<tr>"; echo "<td><strong>Optical:</strong></td>"; echo "<td><input name=optical type=text id=optical size=25 value=".$row[optical]."></td>"; echo "</tr>"; echo "<tr>"; echo "<td><strong>License:</strong></td>"; echo "<td><input name=lic type=text id=li size=25 value=".$row[lic]."></td>"; echo "</tr>"; echo "<tr>"; echo "<td><strong>Other:</strong></td>"; echo "<td><input name=other type=text id=other size=25 value=".$row[other]."></td>"; echo "</tr>"; echo "<tr>"; echo "<td><strong>Price:</strong></td>"; echo "<td><input name=price type=text id=price size=25 value=".$row[price]."></td>"; echo "</tr>"; echo "<tr>"; echo "<td><strong>Admin Notes : </strong></td>"; echo "<td><input name=adminnote cols=25 rows=2 id=adminnote value=".$row[adminnote]."></textarea></td>"; echo "</tr>"; echo "<tr>"; echo "<td> </td>"; echo "<td><input type=submit name=Submit value=\"Update Entry\" /></td>"; echo "</tr>"; echo "</table>"; echo "</form>"; } ?> Any advise would be much appreciated... I am stuck on this... Thanks[/code] Link to comment https://forums.phpfreaks.com/topic/68457-solved-initial-form-value-from-mysql-problem/ Share on other sites More sharing options...
recklessgeneral Posted September 8, 2007 Share Posted September 8, 2007 Hi, I would say that you need to quote the results that are placed in the form. For example: echo "<tr>"; echo "<td><strong>ID:</strong></td>"; echo "<td><input name=id type=text id=id size=25 value=\"".$row[id]."\"></td>"; echo "</tr>"; Add the \" around the values and see what that does. Cheers, Darren. Link to comment https://forums.phpfreaks.com/topic/68457-solved-initial-form-value-from-mysql-problem/#findComment-344182 Share on other sites More sharing options...
00falcon Posted September 8, 2007 Author Share Posted September 8, 2007 Thanks Darren.... That worked a treat.... your a life saver.... Link to comment https://forums.phpfreaks.com/topic/68457-solved-initial-form-value-from-mysql-problem/#findComment-344346 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.