duanpanyang1962 2014-02-20 19:02
浏览 12

PHP数组,迭代表单输入值

Absolutely losing what's left of my mind on this. I've been poring over SO for days and nothing I've tried has got me any progress ...

I have a form which includes a table where user inputs date, location, etc.:

<td class="date"><input class="datepicker" name="date[]" value="" /></td>
<td class="location"><input class="location" name="location[]" value="" /></td>
<td class="artist"><input class="artist" name="artist[]" value="" /></td>
<td class="artist-rep"><input class="artist-rep" name="artist-rep[]" value="" /></td>
<td class="add-delete-row">
    <a href="#" class="delete-row" title="Delete row">Delete</a>
    <a href="#" class="add-row" title="Add a row">Add Row</a>
</td>

The number of rows is inconstant, as user can add rows (jQuery). Each row represents a session date and if I ever get to that square, I'll INSERT them into a 'Sessions' table in the db.

I thought I'd be asking how to write the mySQL query but at this point I can't even echo the values using:

$date1 = $_POST['date'][0];
$date2 = $_POST['date'][1];
$date3 = $_POST['date'][2];

echo "<p class=\"debug\">date 1: " . $date1. "</p>";
echo "<p class=\"debug\">date 2: " . $date2. "</p>";
echo "<p class=\"debug\">date 3: " . $date3. "</p>";

(Nothing is echo'd).

I expect I'll have an array (rows) of arrays (session dates/details), but I'm just lost with php arrays, especially when my attempts to even get values to $_POST fails. And by the way, there are other fields in the form (outside the session dates table) which are $_POSTing just fine and getting into the db (a different table), so I don't understand why these inputs' values are MIA.

Any help much appreciated. I'll be on the bridge, eagerly awaiting help ... or a stiff gust of wind.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
    • ¥15 不小心不正规的开发公司导致不给我们y码,
    • ¥15 我的代码无法在vc++中运行呀,错误很多
    • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
    • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
    • ¥30 ppOCRLabel导出识别结果失败
    • ¥15 Centos7 / PETGEM
    • ¥15 csmar数据进行spss描述性统计分析
    • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
    • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题