get value of textbox in a while loop

Permalink
This isn't a concrete5 question, per say. Although, I'm using concrete5 ;)

I have a form that uses some PHP to echo the form elements to a page
based on how many rows are in mysql. See below:

while($row = mysql_fetch_array($result))
{
$type_id=$row['type_id'];
$type=$row['type'];
echo "<tr>";
echo "<td>" . $row['type_id'] . "</td>";
echo "<td>" . $row['type'] . "</td>";
echo "<td><input type=\"submit\" name=
\"remove[$type_id]\" value=\"Remove\" /></td>";
echo "<td><input type=\"text\" name=\"edit_text
\" size=\"20\" /></td>";
echo "<td><input type=\"submit\" name=
\"edit[$type_id]\" value=\"Edit\" /></td>";
echo "</tr>";
}
?>

When I click on Submit, I want to echo to the page whatever was typed
in the text box (name=\"edit_text\").

How can I do this? I've attached a txt file showing my form.

Please forgive me if my copy/paste doesn't come out well, or is difficult to read.

1 Attachment

 
curtis replied on at Permalink Reply
curtis
If I've understood your question properly, you simply want to know how to access form inputs in the receiving script (the action attribute of the form tag)?

In the file update_row_testing.php, since your form is calling it with method=post, you could do: echo $_POST['edit_text']; to display what was entered into that field.

http://www.php.net/manual/en/reserved.variables.post.php...
t8shter replied on at Permalink Reply
that won't work though b/c there are multiple text boxes with the same name in my form...that has to be the issue, but I don't know how else to get the form printed to the screen. I'm running it through a while loop as shown above.
curtis replied on at Permalink Reply
curtis
Oh I see, you want to have an 'edit_text' field for every row. Append the row id to the name like: name="edit_text_<?= $row->id ?>".

On the receiving script, you'll have to do a bit of work to look for anything in the post array whose key starts with "edit_text_" and has value.