drc4925 2017-03-30 11:57
浏览 64
已采纳

如何将文本区域链接到提交PHP

I'm having a little bit of an issue that I think is simple and I am missing something!

Techs in use: PHP, HTML, SMARTY, MYSQL, JQUERY, JAVASCRIPT

What I am trying to achieve is the following:

HTML:

<form id="form" method="post" accept-charset="utf-8">
  {LOOP}
  <div class="btn-group" data-toggle="buttons">
    <label class="btn verified" style="margin-right:20px; opacity:0.2;"><i class="icmn-radio-checked" style="font-size:10px;color:#01a4f8;"></i>
            <input type="radio" name="frm_verify[]" value="{$ID}" class="verified" ><br>Verified
          </label>
    <label class="btn active notverified" style="margin-right:20px;"><i class="icmn-radio-checked" style="font-size:10px;color:#01a4f8;"></i>
            <input type="radio" name="frm_verifyno[]" value="{$ID}" checked multiple class="notverified"><br>not Verified
          </label>
  </div>

  <textarea class="NOTES" name="verifyno_notes[]" class="form-control"></textarea>
  {LOOP}
</form>

From the above form I am (using PHP) trying to get the notes to correlate to a PHP function > MySQL storage. This form is LOOPED multiple times in output on page see {LOOP}

PHP:

if ( $_POST['submitit'] ) {
for ($x=0; $x<count($_POST['frm_verifyno']); $x++)
{
   $value = $_POST['frm_verifyno'][$x];

// get order details
$result         = $db->query("SELECT * FROM TABLE WHERE id = '".$value."'");
$sDeviceinfo = $result->fetch_assoc();

$result         = $db->query("SELECT claimref FROM SECONDTABLE WHERE id = '".$sDeviceinfo['orderid']."'");
$sClaimref = $result->fetch_assoc();

$userip = $_SERVER['REMOTE_ADDR'];
    $db->query("INSERT INTO
                  THIRDTABLE
                  SET
                  `state` = 'MISSING',
                  `notes` = 'MISSING',
                  `user` = '".addslashes($sAdminDetails['fname'] .' '. $sAdminDetails['lname'])."',
                  `ts` = NOW(),
                  `date` = NOW(),
                  `orderid` = '".addslashes($sDeviceinfo['orderid'])."',
                  `deviceid` = '".addslashes($sDeviceinfo['id'])."',
                  `imei` = '".addslashes($sDeviceinfo['imei'])."',
                  `serial` = '".addslashes($sDeviceinfo['serial'])."',
                  `claimref` = '".addslashes($sClaimref['claimref'])."',
                  `userip` = '".addslashes($userip)."'
                  ");
}
} 

The above WORKS for the radio buttons.

So, my question is, how does one also link in the textareas into this?

I have tried (what i thought was) the same kind of process to get the input sent to PHP correctly so i 'know' which textarea correlates to which mysql row entry.

When this form runs it inserts multiple rows (as per count of the loop)

  • 写回答

1条回答 默认 最新

  • dssu33392 2017-03-30 12:21
    关注

    Seeing the fields are in the same loop, you can just do

    $cnt = count($_POST['frm_verifyno']);
    for ($x=0; $x<$cnt; $x++) {
       $value = $_POST['frm_verifyno'][$x];
       $note= $_POST['verifyno_notes'][$x];
    
    .
    .
    .
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么