gpt4 book ai didi

php - mysql在一个字段中插入多个值

转载 作者:行者123 更新时间:2023-11-29 02:28:57 24 4
gpt4 key购买 nike

我在编程中遇到了小问题,首先我在文本区域添加了一些患者测试,就像这个图像,文本区域的数量可以根据测试元素增加,enter image description here

所以我想将这些插入到一个字段中,但只有一部分在表中更新这是我存储测试的记录表![enter code here][2]

enter image description here

提交结果后,我的报告表中只得到一个结果enter image description here

这是我的文字区号

<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>

我用这段代码插入它

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);
}
}

所以我只想在一个字段中插入所有元素测试,希望你能理解我的英语不好,请原谅,任何想法都将不胜感激......

最佳答案

尝试替换

<textarea name="rep_result_" cols="75">{title}{txt}</textarea>

<textarea name="rep_result[]" cols="75">{title}{txt}</textarea>

因为您在不同的区域使用相同的名称,所以 php 只使用最后一个文本区域....所以你需要名称作为数组..

关于php - mysql在一个字段中插入多个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15925171/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com