Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/56.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_Mysql_Oop_Sql Update - Fatal编程技术网

Php 更新查询仅使数据库表字段为空

Php 更新查询仅使数据库表字段为空,php,mysql,oop,sql-update,Php,Mysql,Oop,Sql Update,我用PHP OOP做了一个更新查询。基本上,这里是itemedit.php页面,用户可以在其中更新数据库表字段: <form action='itemedit.php?i=$i' method='POST'> <td>$i</td> <td><input type='text' name='e

我用PHP OOP做了一个更新查询。基本上,这里是
itemedit.php
页面,用户可以在其中更新数据库表字段:

    <form action='itemedit.php?i=$i' method='POST'>
                                    <td>$i</td>
                                    <td><input type='text' name='e' value='".$menuSet->$func()."'/></td>
                                    <td>
                                        <input type='submit' value='Edit'/>&nbsp; 
                                        <a title='Remove' href='itemdelete.php?i=$i'><span class='glyphicon glyphicon-remove'></span></a>
                                    </td>
                                    </tr>
                                    </form>
以下是该表格文件的操作:

if (isset($_GET['i'])){
    $i = $_GET['i'];
    $e = $_POST['e'];
    $editItem = new Menus();

    if(isset($_POST['yes'])){
        $editItem->EditMenuItem($i,$e);
        echo '<META HTTP-EQUIV="Refresh" Content="0; URL=menus.php">';   
        exit; 
    }
    if(isset($_POST['no'])){
        echo '<META HTTP-EQUIV="Refresh" Content="0; URL=menus.php">';    
        exit; 
    }

    echo "
    <div class='content-wrapper'>
        <section class='content-header'>
            <h1>
                Editing Menu Item
                <small></small>
            </h1>
            <ol class='breadcrumb'>
                <li class='active'>itemedit.php</li>
            </ol>
        </section>
        <section class='content' style='text-align:center;'>
            <form action='' method='POST'>
                <h5><strong> 
                    Are you sure you want to change the selected item ?</br></br>
                </strong></h5>   
                <p> 
                    <button name='yes' type='submit' class='btn btn-primary'>Yes</button>
                    <button name='no' type='submit' class='btn'>No</button>
                </p> 
            </form> 
        </section>
    </div>
    ";
if(isset($\u GET['i'])){
$i=$_GET['i'];
$e=$_POST['e'];
$editItem=新菜单();
如果(isset($_POST['yes'])){
$editItem->EditMenuItem($i,$e);
回声';
出口
}
如果(isset($_POST['no'])){
回声';
出口
}
回声“
编辑菜单项
  • itemedit.php
  • 是否确实要更改所选项目

    对 不

    ";
    它工作得很好,但问题是由于某些原因,它只会使MySQL数据库中的表字段为空


    因此,如果您知道如何解决这个问题,请告诉我,我真的很感谢您的帮助?

    这是因为在第二次迭代中,当用户选择是或否时,表单没有
    $\u POST['e']
    的值

    改变这个

    <p>
    <button name='yes' type='submit' class='btn btn-primary'>Yes</button>
    <button name='no' type='submit' class='btn'>No</button>
    </p> 
    
    
    对
    不
    

    
    
    如何/何时调用此函数
    EditMenuItem
    ?很抱歉,我忘了记下它,请再次查看问题
    <p>
    <button name='yes' type='submit' class='btn btn-primary'>Yes</button>
    <button name='no' type='submit' class='btn'>No</button>
    </p> 
    
    <p>
    <input type='hidden' name='e' value='<?php echo $e;?>'>
    <button name='yes' type='submit' class='btn btn-primary'>Yes</button>
    <button name='no' type='submit' class='btn'>No</button>
    </p>