gterre Posted August 24, 2006 Share Posted August 24, 2006 Hello,I am stuck on this one problem which I bet is really simple. I am trying to create an edit form which shows the current data in each respective fields. I know its down by assigning the value="" attribute of the form field. however i need to query the database for the record in question and assign the results of the query into variables so i can insert into the value attribute. Can someone give me an example of pulling a query and setting the results for each field into a variable?Thank you this help is much appreciated. Quote Link to comment Share on other sites More sharing options...
tomfmason Posted August 24, 2006 Share Posted August 24, 2006 I think that this is what you want[code=php:0]$sql = mysql_query("SELECT * From `sometable` WHERE `something` = '$something'")or die(mysql_error());while ($rw = mysql_fetch_assoc($sql)) { echo '<input type="text" name="' . $rw['some_field'] . '" value="' . $rw['somefield'] . '"> <input type="text" name="' . $rw['some_field2'] . '" value="' . $rw['somefield2'] . '">';}mysql_free_result($sql);[/code]Hope this helps,Tom 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.