【发布时间】:2015-01-15 13:14:01
【问题描述】:
我有许多 php 表单和一个 csv 文件来存储所有内容。csv 文件已经包含现有数据。我需要执行以下操作: 当按下提交按钮时,打开 csv 文件并检查特定字段是否为空(参考编号只是将表单链接在一起的一种方式,因为每个表单都是由不同的人完成的)。 如果是粘贴第一个字段 然后继续下一个,依此类推 然后,当在另一个表单上按下提交时,检查以找到匹配的参考号并将值粘贴到每个单元格中。 该行将保持不变,但每个列都特定于每个表格,例如我有 B E 和 F 用于表格 1 A D G 用于表格 2 等等。
谁能给我一个例子来说明如何做到这一点? 谢谢
<html>
<head><title>Network Design Request</title></head>
<title>Design Request</title>
<form action="exec-data.php" method="POST">
<fieldset align="left">
<legend>Executive Sponsor Form</legend>
<p><i>To be completed by the executive sponsor</i></p>
<table>
<tr>
<td>Refrence Number:</td>
<td><?php $Ref = new DateTime();
echo $Ref->format('U') . "\n";
?>
</td></tr>
<tr>
<td>Name:</td><td><input type="text" name="SNAME" size="40" /></td>
</tr>
<tr>
<td>Position:</td><td><input type="text" name="SPOSITION" size="40" /></td>
</tr>
<tr>
<td>Telephone Number:</td><td><input type="text" name="SNUMBER" size="40" maxlength="11" /></td>
</tr>
<tr>
<td>Email Address:</td><td><input type="email" name="SEMAIL" size="40" /></td>
</tr>
<tr>
<td>Budget Available:</td><td><input type="checkbox" /><input type="text" name="BUDGET" size="37" maxlength="6" placeholder="2014 budget submission code" /></td>
</tr>
<tr>
<td>Aligned to which<br>priority:</td><td><input type="text" name="PRIORITIES" size="40" /></td>
</tr>
</form>
这是其中一种形式,我目前的代码是:
<?php
$inputFileType = 'csv';
$inputFileName = '\Documents\Network Design Project\Notepad++ndr_db.csv';
$sheetname = '2015 Jan';
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objReader->setLoadSheetsOnly($sheetname);
$objReader = $objReader->load($inputFileName);
$Refrow = 1
$Refcol = 2
foreach ($data as $Refrow){
if ($Refrow is_null){$Refrow++}
else ($_POST['$Ref'] )
}
$Exec_col = 5
$Exec_row = 1
foreach ($data as $Exec_row){
if ($Exec_row is_null){$Exec_row++}
else ($_POST['SNAME'] )
}
?>
【问题讨论】:
-
本网站不是代码编写服务。展示您到目前为止所做的工作,并说明您在使用现有代码时遇到的问题。
标签: php forms csv web-applications spreadsheet