PHP:更新数据库时未定义索引错误

时间:2015-11-21 20:12:13

标签: php database mysqli

我在文本字段中获取数据,然后尝试像这样更新它  然后在底部,这就是我正在做的事情

<?php                      
    $query= mysqli_query($connect,"SELECT * FROM page");
    while ($row = mysqli_fetch_assoc($query))
    if(isset($_GET['edit'])){?>
    <h1>About us </h1>
    <form >
        <div class="form-group"><textarea class="form-control" rows="10" name="con"><?php echo   $row['content'] ?></textarea></div>;
        <div class="form-group"> <strong>Projects Completed :</strong><input type="text" class="form-control" name="progress" value= "<?php echo $row['projects_completed']?>" ></div>
        <div class="form-group"> <strong>Projects In Progress :</strong><input type="text" class="form-control" name="done" value="<?php echo $row['projects_running']?>"> </div>        
        <a class="btn btn-primary"   href="about-us.php?update">Update</a>
    </form>
    <?php 
        }

    else{?>
        <a  class="btn btn-default pull-right" href="about-us.php?edit" name="edit">Edit</a>
        <h1>About us </h1>
        <?php 
            echo '<p>'.$row['content'].'</p>';
            echo  '<p><strong>Projects Completed :</strong>' .$row['projects_completed'].'</p>';
            echo  '<p> <strong>Projects Completed :</strong>' .$row['projects_running'].'</p>';
        ?>
    <?php };


?>

<?php if (isset($_GET['update'])) {
      $name= $_GET['content'];
      echo $name; 
?>

这是我得到的错误

  

注意:未定义的索引:C:\ wamp \ www ...

中的内容

请帮我解决这个问题,

1 个答案:

答案 0 :(得分:0)

您看到的通知消息说数组$_GET没有content索引。你可以这样做:

if (key_exists('content', $_GET)) {...} else {...}

而不是

if (isset($_GET['update'])) ...