Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.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
Php 创建空表并插入数据_Php_Html_Mysql - Fatal编程技术网

Php 创建空表并插入数据

Php 创建空表并插入数据,php,html,mysql,Php,Html,Mysql,我想创建一个表来执行在这里输入代码插入、更新和删除 其想法是将表单替换为一个表,例如,在填充第一行后,创建一个只有标题和空行的表,准备插入数据,或者动态创建第二行,或者放置一个按钮“添加行”并返回以写入内容和插入,等等。 我正在尝试这种方式,但我无法在列中写入,然后执行插入: <table id="products-table"> <tbody> <tr> <th>Produto&

我想创建一个表来执行
在这里输入代码
插入、
更新
删除

其想法是将表单替换为一个表,例如,在填充第一行后,创建一个只有标题和空行的表,准备插入数据,或者动态创建第二行,或者放置一个按钮“添加行”并返回以写入内容和插入,等等。 我正在尝试这种方式,但我无法在列中写入,然后执行插入:

<table id="products-table"> 
    <tbody>  
        <tr>       
            <th>Produto</th>       
            <th>Código</th>    
            <th>Quantidade</th>    
            <th>Preço</th>     
            <th>Ações</th>   
        </tr>   
        <tr>       
            <td>&nbsp;</td>    
            <td>&nbsp;</td>    
            <td>&nbsp;</td>    
            <td>&nbsp;</td>    
            <td>         
            <button onclick="RemoveTableRow(this)" type="button">Remover</button>      
            </td>    
        </tr>   
    </tbody>    
    <tfoot>  
        <tr>      
            <td colspan="5" style="text-align: left;">
                <button onclick="AddTableRow()" type="button">Adicionar Produto</button>      
            </td>   
        </tr>   
    </tfoot>    
</table>    

<script>
(function($) {
    AddTableRow = function() {  
    var newRow = $("<tr>");     var cols = "";  
    cols += '<td>&nbsp;</td>';  
    cols += '<td>&nbsp;</td>';  
    cols += '<td>&nbsp;</td>';  
    cols += '<td>&nbsp;</td>';  
    cols += '<td>';  
    cols += '<button onclick="RemoveTableRow(this)" type="button">Remover</button>';
    cols += '</td>';    
    newRow.append(cols);    
    $("#products-table").append(newRow);    
    return false;   
    };
})(jQuery); 
</script> 

普罗杜托
科迪戈
量子化
普雷西奥
Ações
搬运工
阿迪西奥纳生产商
(函数($){
AddTableRow=函数(){
var newRow=$(“”);var cols=“”;
cols+='';
cols+='';
cols+='';
cols+='';
cols+='';
cols+=‘去除剂’;
cols+='';
newRow.append(cols);
$(“#产品表”).append(newRow);
返回false;
};
})(jQuery);

但我想问,创建一个表来替换html中的表单有意义吗

这是有道理的,我建议您看一看,哪种方法使您能够通过适当的回调和其他方式处理此类用例。唯一的限制是您需要jQuery