drc4925 2017-03-30 03: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 04: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];
    
    .
    .
    .
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部