0

I have textarea in the UI which i display text inside it from db and the user edits it and clicks on update button.

while($row=$stmt->fetch(PDO::FETCH_NUM,PDO::FETCH_ORI_NEXT)){

<textarea  id= <?php echo $row5[0]; ?> name='upAncText[]' rows=1 cols=40> <?php echo $row5[1]; ?> </textarea><br/> 

}

Now when i click on update i have to read the id and texarea value inorder to insert into DB. could anyone let me know how to do this in php?

1
  • This is the subject of every basic PHP/mySQL tutorial. You might be better of systematically going through one of them, as there are some pitfalls to this (e.g. XSS attacks and SQL injection) Commented Nov 10, 2011 at 0:50

1 Answer 1

1

Change your textarea to something like this:

// Are you sure you want $row5 and not $row ?
<textarea name="upAncText[<?= $row5[0]; ?>]"></textarea>

Now, when you grab $_POST['upAncText'], it will be an array with keys that are the textarea ID and values that are the user input.

FYI, <?= ?> is shorthand for <?php echo ?>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.