dongmei8209 2015-02-18 06:17
浏览 24
已采纳

如何在单个变量中追加不同的Array值

<tr>
    <td><p style="color:#999; font-size:14px; text-align:right;">Please select your Board :</p></td>
    <td>
    <input type="checkbox" name="board[]" id="all" value="cbse">CBSE
    <input type="checkbox" name="board[]" id="sci" value="cse/Ise">ICSE/ISE
    <input type="checkbox" name="board[]" id="mat" value="State">State
    <input type="checkbox" name="board[]" id="mat" value="International">International
    </td>
    </tr>

    <tr>
    <td><p style="color:#999; font-size:14px; text-align:right;">Please select Subject :</p></td>       
    <td>      
    <input type="checkbox" name="classfivesubject[]" id="all" value="allsubject">All Subject
    <input type="checkbox" name="classfivesubject[]" id="sci" value="science">Science
    <input type="checkbox" name="classfivesubject[]" id="mat" value="maths">Maths
    </td>
    </tr><!--end of select subject row-->

Here are my PHP values:

$segment=$_SESSION["segment"];
$board=$_POST['board'];
$subject5=$_POST['classfivesubject'];
$segment=implode(",",$segment);
$board=implode(",",$board);
$class5data=implode(",",$subject5);

Again for class8:

$eightboard=$_POST['eightboard'];
$subject8=$_POST['classeightsubject'];
$board=implode(",",$eightboard);
$class8data=implode(",",$subject8);

I want store the values like this in my database in a column: classconducted.

segment:class I_V
Board:CBSE,STATE
Subject:AllSubject,Maths,Science

segment:class V-VIII
Board:CBSE, STATE
SUbject:AllSubject,Maths,Science

My question is how to append all the values in single variable. Assume variable name is classconducted. So that based on the tutor selection class conducted I bring all the data into a single variable and put it into a single column. I hope you understand my question because each tutor is conducting different standard and different subject and different medium. How do I bring all the values in single variable?

I want output like this: classconducted.

    segment:class I_V
    Board:CBSE,STATE
    Subject:AllSubject,Maths,Science

    segment:class V-VIII
    Board:CBSE, STATE
    SUbject:AllSubject,Maths,Science
  • 写回答

1条回答 默认 最新

  • doumengwei0138 2015-02-18 06:27
    关注

    You can store json encoded data into a single column like

    $classconducted = json_encode(array('segment'=>'your segment value','Board'=>'board value','Subject'=>'subject value'));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog