drc4925
2017-03-30 11:57
浏览 62

如何将文本区域链接到提交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];
    
    .
    .
    .
    
    点赞 打赏 评论

相关推荐 更多相似问题