Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/431.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 更新表格html并保存为csv_Javascript_Php_Codeigniter_Csv - Fatal编程技术网

Javascript 更新表格html并保存为csv

Javascript 更新表格html并保存为csv,javascript,php,codeigniter,csv,Javascript,Php,Codeigniter,Csv,我是php codeigniter的初学者 如何更新来自CSV文件的数据的现有数据 例如,我想编辑第3行并保存它。当我打开CSV文件时,我在web表html中编辑的行应该更新CSV文件,因此当我打开CSV文件时,它应该已经在那里了。不需要在这里创建数据库 请帮帮我谢谢你 下面是我的编辑代码,当您单击它时,文本框将显示在所有受影响的行中。在我看来,这是我的javascript 查看 function Edit(){ var par = $(this).parent().pa

我是php codeigniter的初学者

如何更新来自CSV文件的数据的现有数据

例如,我想编辑第3行并保存它。当我打开CSV文件时,我在web表html中编辑的行应该更新CSV文件,因此当我打开CSV文件时,它应该已经在那里了。不需要在这里创建数据库

请帮帮我谢谢你

下面是我的编辑代码,当您单击它时,文本框将显示在所有受影响的行中。在我看来,这是我的javascript

查看

function Edit(){
            var par = $(this).parent().parent(); //tr
            var f1 = par.children("td:nth-child(1)");
            var f2 = par.children("td:nth-child(2)");
            var f3 = par.children("td:nth-child(3)");
            var f4 = par.children("td:nth-child(4)");
            var f5 = par.children("td:nth-child(5)");
            var f6 = par.children("td:nth-child(6)");
            var f7 = par.children("td:nth-child(7)");
            var f8 = par.children("td:nth-child(8)");
            var f9 = par.children("td:nth-child(9)");
            var f10 = par.children("td:nth-child(10)");
            var f11 = par.children("td:nth-child(11)");
            var f12 = par.children("td:nth-child(12)");
            var f13= par.children("td:nth-child(13)");
            var f14 = par.children("td:nth-child(14)");
            var f15 = par.children("td:nth-child(15)");
            var f16 = par.children("td:nth-child(16)");
            var f17 = par.children("td:nth-child(17)");

            f1.html("<input type='text' name='f1' id='f1' value='"+f1.html()+"'/>");
            f2.html("<input type='text' name='f2' id='f2' value='"+f2.html()+"'/>");
            f3.html("<input type='text' name='f3' id='f3' value='"+f3.html()+"'/>");
            f4.html("<input type='text' name='f4' id='f4' value='"+f4.html()+"'/>");
            f5.html("<input type='text' name='f5' id='f5' value='"+f5.html()+"'/>");
            f6.html("<input type='text' name='f6' id='f6' value='"+f6.html()+"'/>");
            f7.html("<input type='text' name='f7' id='f7' value='"+f7.html()+"'/>");
            f8.html("<input type='text' name='f8' id='f8' value='"+f8.html()+"'/>");
            f9.html("<input type='text' name='f9' id='f9' value='"+f9.html()+"'/>");
            f10.html("<input type='text' name='f10' id='f10' value='"+f10.html()+"'/>");
            f11.html("<input type='text' name='f11' id='f11' value='"+f11.html()+"'/>");
            f12.html("<input type='text' name='f12'id='f12' value='"+f12.html()+"'/>");
            f13.html("<input type='text' name='f13' id='f13' value='"+f13.html()+"'/>");
            f14.html("<input type='text' name='f14' id='f14' value='"+f14.html()+"'/>");
            f15.html("<input type='text' name='f15' id='f15' value='"+f15.html()+"'/>");
            f16.html("<input type='text' name='f16' id='f16' value='"+f16.html()+"'/>");
            f17.html("<a onclick='edit_submit();' style='cursor: pointer;'>Save</a>");


            $(".btnSave").bind("click", Save);
            $(".btnEdit").bind("click", Edit);
            $(".btnDelete").bind("click", Delete);
        };

您应该看看codeigniter中的文件库

write_文件('path',$data)应该执行您想要的操作

从这里得到的


谢谢您的帮助,但我已经在PHP中使用并尝试了文件系统功能。它帮助我添加我使用的新数据
a
append
它将在文件的
末尾添加新数据
,但我的问题是编辑。我应该用什么?
function edit()
{
    $R1 = $this->input->post('f1');
    $R2 = $this->input->post('f2');
    $R3 = $this->input->post('f3');
    $H1 = $this->input->post('valh1');
    $R4 = $this->input->post('f4');
    $R5 = $this->input->post('f5');
    $H2 = $this->input->post('valh2');
    $H3= $this->input->post('valh3');
    $R6 = $this->input->post('f6');
    $R7 = $this->input->post('f7');
    $R8 = $this->input->post('f8');
    $R9 = $this->input->post('f9');
    $R10 = $this->input->post('f10');
    $R11 = $this->input->post('f11');
    $R12 = $this->input->post('f12');
    $R13 = $this->input->post('f13');
    $H4 = $this->input->post('valh4');
    $R14 = $this->input->post('f14');
    $R15 = $this->input->post('f15');
    $R16 = $this->input->post('f16');

    $data = $R1.",".$R2.",".$R3.",".$H1.",".$R4.",".$R5.",".$H2.",".$H3.",".$R6.",".$R7.",".$R8.",".$R9.",".$R10.",".$R11.",".$R12.",".$R13.",".$H4.",".$R14.",".$R15.",".$R16;
    $list = array($data);

    $file = fopen("./bin/pdw_table.csv","a");

    foreach ($list as $line)
    {
        fgetcsv($file,explode(',',$line));
    }

    fclose($file);
    redirect('datacast_ctr');
}