久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

輸出一個php多維數組到一個html表

Output a php multi-dimensional array to a html table(輸出一個php多維數組到一個html表)
本文介紹了輸出一個php多維數組到一個html表的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個包含 8 列和可變行數的表單,我需要以格式良好的電子郵件將其通過電子郵件發送給客戶.該表單將所需字段作為多維數組提交.粗略的例子如下:

I have a form that has 8 columns and a variable number of rows which I need to email to the client in a nicely formatted email. The form submits the needed fields as a multidimensional array. Rough example is below:

<input name="order[0][topdiameter]" type="text" id="topdiameter0" value="1" size="5" />
<input name="order[0][bottomdiameter]" type="text" id="bottomdiameter0" value="1" size="5" />
<input name="order[0][slantheight]" type="text" id="slantheight0" value="1" size="5" />
<select name="order[0][fittertype]" id="fittertype0">
    <option value="harp">Harp</option>
    <option value="euro">Euro</option>
    <option value="bulbclip">Regular</option>
</select>
<input name="order[0][washerdrop]" type="text" id="washerdrop0" value="1" size="5" />
<select name="order[0][fabrictype]" id="fabrictype">
    <option value="linen">Linen</option>
    <option value="pleated">Pleated</option>
</select>
<select name="order[0][colours]" id="colours0">
    <option value="beige">Beige</option>
    <option value="white">White</option>
    <option value="eggshell">Eggshell</option>
    <option value="parchment">Parchment</option>
</select>
<input name="order[0][quantity]" type="text" id="quantity0" value="1" size="5" />

此表單以表格形式格式化,并且可以動態地向其中添加行.我一直無法做的是從數組中獲取格式正確的表.

This form is formatted in a table, and rows can be added to it dynamically. What I've been unable to do is get a properly formatted table out of the array.

這就是我現在使用的(從網上抓取的).

This is what I'm using now (grabbed from the net).

<?php
if (isset($_POST["submit"])) {
$arr= $_POST['order']
echo '<table>';
foreach($arr as $arrs)
    {
    echo '<tr>';
    foreach($arrs as $item)
    {
        echo "<td>$item</td>";
    }
    echo '</tr>';
    }

echo '</table>;
};
?>

這對于單行數據非常有效.如果我嘗試從表單提交 2 行或更多行,則其中一列會消失.我希望表格的格式為:

This works perfectly for a single row of data. If I try submitting 2 or more rows from the form then one of the columns disappears. I'd like the table to be formatted as:

| top | Bottom | Slant | Fitter | Washer | Fabric | Colours | Quantity |
------------------------------------------------------------------------
|value| value  | value | value  | value  | value  |  value  |  value   |

根據需要添加額外的行.但是,我找不到任何可以生成這種類型表的示例!

with additional rows as needed. But, I can't find any examples that will generate that type of table!

看起來這應該是相當簡單的事情,但我只是找不到一個可以按照我需要的方式工作的示例.

It seems like this should be something fairly straightforward, but I just can't locate an example that works the way I need it too.

推薦答案

在您的 HTML 中,嘗試如下操作:

In your HTML, try something like this:

<table>
<tr>
  <th>Bottom</th>
  <th>Slant</th>
  <th>Fitter</th>
</tr>
<?php foreach ($_POST['order'] as $order): ?>
  <tr>
    <td><?php echo $order['bottomdiameter'] ?></td>
    <td><?php echo $order['slantheight'] ?></td>
    <td><?php echo $order['fittertype'] ?></td>
  </tr>
<?php endforeach; ?>
</table>

顯然,我沒有把你的所有屬性都包括在內,但希望你能明白.

Obviously, I'm not including all your attributes there, but hopefully you get the idea.

這篇關于輸出一個php多維數組到一個html表的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 精品久久久久久 | 夜夜爽99久久国产综合精品女不卡 | 欧美理伦片在线播放 | 色婷婷综合久久久久中文一区二区 | 91精品国产色综合久久不卡蜜臀 | 亚洲精品欧美一区二区三区 | 欧美精品片 | 99日韩 | 欧美日韩三级在线观看 | 亚洲精品久久久久中文字幕欢迎你 | av网站在线看| 日韩免费av | 久久成人一区 | 国产一区在线免费 | 国产日韩一区二区 | 丁香婷婷久久久综合精品国产 | www.天天操.com | 精品美女 | 日韩在线一区视频 | 国产激情一区二区三区 | 欧美一级久久 | 国产一区二区三区不卡av | 国产午夜精品一区二区三区 | 美日韩免费 | 亚洲精品久久久一区二区三区 | 激情小说综合网 | 成人在线精品 | 欧美日韩精品一区 | 国产日韩欧美一区二区 | 亚洲一区视频在线 | 日韩精品免费视频 | 免费小视频在线观看 | 农村黄性色生活片 | 91最新在线视频 | 精品免费视频一区二区 | 日韩免费中文字幕 | 久久九九网站 | 一区二区三区日韩精品 | 另类亚洲视频 | 免费国产一区二区 | 久久精品亚洲一区二区三区浴池 |