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. Link to comment https://forums.phpfreaks.com/topic/18569-take-results-from-a-mysql-query-and-assign-to-variables/ 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 Link to comment https://forums.phpfreaks.com/topic/18569-take-results-from-a-mysql-query-and-assign-to-variables/#findComment-79988 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.