deansaddigh Posted April 6, 2010 Share Posted April 6, 2010 Hi, i have this code //Get the id $id = $_GET["id"]; $query = "SELECT * FROM faq WHERE faq_id =$id"; $result = mysql_query($query, $conn) or die('Error, query failed'); while($row= mysql_fetch_array($result)) { echo '<strong>Question:</strong> <p class="important2">'.$row['question'].'</p>'; echo '<strong>Answer:</strong> <p class="important2">'.$row['answer'].'</p>'; echo '<hr/> '; } Basically i want to be able to modify the question and answer in a form and then update the record, how can i do this? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/197745-how-to-put-a-field-pulled-from-db-into-txt-area/ Share on other sites More sharing options...
Pikachu2000 Posted April 6, 2010 Share Posted April 6, 2010 If I'm reading the question right, you want to be able to edit what is returned from the DB and update those same DB fields with the data entered in the form fields, correct? If so, to populate the text areas use echo '<input type="hidden" name="record_id" value="' . $row['record_id'] . '" />' echo '<textarea name="question" rows="3" cols="40">' . $row['question'] . '</textarea>'; Then when the form is submitted (check for submission with an isset() ), sanitize the input and run the UPDATE query, setting the fields to the new values WHERE the db_record_id = submitted_record_id. Link to comment https://forums.phpfreaks.com/topic/197745-how-to-put-a-field-pulled-from-db-into-txt-area/#findComment-1037761 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.