Reputation: 447
I have small issue in programming, first i added some test of patient in text area like this image, the number of textarea can increase according to element of tests,
so i want to to insert these in one field but only one part is updating in table
this is my record table where tests are stored![enter code here][2]
and after submit result i get only one result in my report table
and this is my text area code
<div style="border:solid 2px #000; margin:2px;">
<span style="padding:5px; font-size:14px; color:#FF0000;">{title}</span>
<textarea name="rep_result_" cols="75">{title}{txt}</textarea>
</div>
and i am inserting it with this code
gri("records","WHERE payment_id='$R[payment_id]' ","",$records);
$dt = time();
foreach($R as $k=>$v)
{
$test_id = str_replace('rep_result_', '', $k);
if(strstr($k, 'rep_result_'))
{
$content = $v;
$SQL = "INSERT INTO report SET
rep_te_id = '$records[test_id]',
rep_result = '$content',
record_id = '$records[id]',
rep_date = '$dt'";
ei($SQL);
}
}
so i just want to insert all element test in one field, hope u understand for bad english i excuse, any idea will be highly appreciated...
Upvotes: 2
Views: 971
Reputation: 6950
try replacing
<textarea name="rep_result_" cols="75">{title}{txt}</textarea>
with
<textarea name="rep_result[]" cols="75">{title}{txt}</textarea>
since you are using same name for different areas so php is taking only last textarea.... so you need the name as array..
Upvotes: 2
Reputation: 5306
you can add [] to your textarea name like
<textarea name="rep_result_[]" cols="75">{title}{txt}</textarea>
so you will have an array of entered values with $_POST['rep_result_'], then iterate through them and insert table.
Upvotes: 0