【问题标题】:posting array in php from a table从表中在 php 中发布数组
【发布时间】:2011-07-31 09:15:22
【问题描述】:

有这个 html 页面,我在其中输入一些字段并在 php.ini 中发布所有值。这是我的html代码:

     <form action = 'preViewTallyHdr.php' method = 'POST' target="_blank">
        <p>Supplier Name & contact person:
          <input class = 'supplier' type = 'text' id = 'supplierInput' value = '' STYLE="color: blue"; size="47" name = "supplier">
        </p> 
        <p>Wood specie description: 
          <input class = 'woodSpe' type = 'text' id = 'woodSpecie' value = ''STYLE="color: blue"; size = "55" name = "wood">
        </p>
        <!--this is for viewing newly added planks (jqgrid)-->
        <table id="plankList"  name="plankList[]"></table>
        <div id="pgrid"></div>

        <!--this button will open another dialog (dialogAdd) for adding new plank-->        
        <input type ='button' id="btnAddnew" value = 'Add Plank'>   
        <input type = "Submit" value="Preview">  
     </form>

    <div id="dialogAdd" title="Plank Entry"> 
      <form method="post" action="#" id="plank_form">        
        <p>Plank number :
        <input type="text" class="integer" name="plank_number" id="plank_number"/></p>
        <p>Thickness:
        <input type="text" class="numeric" name="thickness" id="thickness"/></p>
        <p>Width:
        <input type="text" class="numeric" name="width" id="width"/></p>
        <p>Length:
        <input type="text" class="numeric" name="length_t" id="length_t"/></p>
        <p>Quantity:
        <input type="text" class="integer" name="quantity" id="quantity"/></p>
      </form>
    </div>  

每次我添加一个新木板时,我都会在我的 jqgrid 中创建一个这样的数组:

[{"plank_number":"1","thickness":"5","width":"7","length_t":"8","quantity":"1"},
 {"plank_number":"2","thickness":"5","width":"6","length_t":"7","quantity":"1"},
 {"plank_number":"3","thickness":"6","width":"7","length_t":"8","quantity":"1"}]

并将根据用户输入的木板数量继续。

我已经有一个可以输出我的供应商和木材种类的 .php 文件,但我不知道如何在其中显示我的发布表数据。下面是我在 php 中的代码(没有显示表格的代码)。

  <p>Supplier Name & contact person:<?php echo $_POST['supplier'];?><br/>
      </p> 
  <p>Wood specie description:<?php echo $_POST['wood'];?>
      </p>
  <?php 
        //this is for my table which i don't know how to start
  ?>

另外,我也可以根据我的数据制作表格吗?

【问题讨论】:

    标签: php html arrays post


    【解决方案1】:
    <table id="plankList"  name="plankList[]"></table>
    

    我不确定上面的 html 标记是否正确..

    如果你有这样的数组或json格式

    [{"plank_number":"1","thickness":"5","width":"7","length_t":"8","quantity":"1"},
    {"plank_number":"2","thickness":"5","width":"6","length_t":"7","quantity":"1"},
    {"plank_number":"3","thickness":"6","width":"7","length_t":"8","quantity":"1"}]
    

    您可以在 ajax 请求 (jquery) 中发布此内容。

    【讨论】:

    猜你喜欢
    • 2012-07-27
    • 1970-01-01
    • 2015-06-12
    • 2010-09-30
    • 1970-01-01
    • 2011-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多