将项目从listbox1移到listbox2并将listbox2保存到csv文件

时间:2020-04-05 17:02:19

标签: php csv listbox save

我有以下工作代码将项目从通过csv文件(master.csv)填充的一个列表框中移动到也通过csv文件(purchases.csv)填充的另一个列表框中。如何保存已移动到csv的项目文件(purchases.csv)

<div class="column"> 
<h1>Master List</h1>
Hold the Ctrl key for multiple selections<br /><br />
<select name=master[] id=master class="master" multiple="multiple" size='23'>
<?php   
    $file = fopen("master.csv", "r");
    fgetcsv($file, 10000, ",");
    fgetcsv($file, 10000, ",");
    fgetcsv($file, 10000, ",");
    fgetcsv($file, 10000, ",");
    fgetcsv($file, 10000, ",");
    while (($row = fgetcsv($file, 0, ",")) !== FALSE) {
        $master = $row[1];
?>
    <option value="<?php echo $master;?>"><?php echo $master;?></option>
<?php
    }
?>
</select>

<div class="column">
     <td align=center valign=middle>

<h1>Purchases List</h1>
<form action="upload.php" method="post" enctype="multipart/form-data"><br />
    <input type=button class="master" name=b1 id=b1 value='Move >'>
    <input type=button class="master" name=b2 id=b2 value='< Remove'>
<select name=purchases[] id=purchases class=master>
<?php   
    $file = fopen("purchases.csv", "r");
    while (($row = fgetcsv($file, 0, ",")) !== FALSE) {
        $purchases = $row[0];
?>
    <option value="<?php echo $purchases;?>"><?php echo $purchases;?></option>
<?php
    }
?>
</select>

是否可以使用onclick按钮进行保存

<input type="submit" value="Save File" name="master">

0 个答案:

没有答案