Jump to content

Recommended Posts

I have a form that is has a single text area for each individual school assignment. These textareas are generated by how many there are in the database. The names of the textareas are assignment[$id] with the assignment's unique id inside. It would be impossible to individually name each one because there could be more than twenty assignments. How can I go about retrieving the text in the textarea and its id to insert it into a database?

Is it something like this?

$assignment = array();
$assignment = $_POST["assignment"];
foreach ($assignment as $task) {
$q = mysql_query("UPDATE table SET `assignment` = '$assignment' WHERE `id` = '$assignment[]'");

You basically have it, assuming you have the form like this

<input name="assignment[<?php echo $id; ?>]">

you could be able to do this

$assignment = $_POST["assignment"];
foreach ($assignment as $ID => $task) {
$q = mysql_query("UPDATE table SET `assignment` = '$task' WHERE `id` = '$ID'");

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.