duanjiang7505 2016-08-03 05:04
浏览 114
已采纳

从wordpress中的二维数组中获取值

I am using a two dimensional array for inputting value from custom field. like this

  <input type="text" name="education[0][edu_title]" placeholder="Title">
  <input type="date" name="education[0][edu_to]" placeholder="To" class="calendar">

It is a loop that is value of 0 is changed to 1 and so on. Now if the form is submitted i want to get each value.

  $tableedu = $wpdb->prefix . 'apply_edu';
    $education=$pst_data['education'];
    $sqldataedu = array();
    $count=0;
    foreach($education as $edu){
        $sqldataedu['edu_title'] = stripslashes($edu[$count]['edu_title']);
        $sqldataedu['edu_from'] = stripslashes($edu[$count]['edu_from']);
        $sqldataedu['edu_to'] = stripslashes($edu[$count]['edu_to']);
        $sqldataedu['edu_institute'] = stripslashes($edu[$count]['edu_institute']);
        $sqldataedu['apply_id'] = $lastid;
        $wpdb->insert($tableedu, $sqldataedu);
        $count++;
        }

how can i store each value in database

  • 写回答

1条回答 默认 最新

  • dongpu3898 2016-08-03 05:48
    关注

    Try this save data in database.

    $education = $_POST['education'];
    foreach( $education as $arr ){
      $insert_data= array();
      $insert_data['edu_title'] = stripslashes($arr['edu_title']);
      $insert_data['edu_from'] = stripslashes($arr['edu_from']);
      $insert_data['edu_to'] = stripslashes($arr['edu_to']);
      $insert_data['edu_institute'] = stripslashes($arr['edu_institute']);
      $insert_data['apply_id'] = $lastid;
      $wpdb->insert($tableedu, $insert_data);
    
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助