Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.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_Session - Fatal编程技术网

Php 选择查询后不刷新页面的数据更新

Php 选择查询后不刷新页面的数据更新,php,mysql,session,Php,Mysql,Session,如果我看起来很傻,请原谅我 我的问题是,我有一个配置文件页面,在更新和提交数据库中的数据更改时。然后,为了刷新数据,我使用selectquery。然后我将其保存在当前会话中。但是,这些更改只发生在更新和选择查询显示的页面中。我有一些网页,其中包括像顶栏,左导航。只有在刷新页面时才会更改。我的代码如下 <?php if(isset($_POST['update'])) { $name_t = $_POST['name']; $email_t = $

如果我看起来很傻,请原谅我

我的问题是,我有一个配置文件页面,在更新和提交数据库中的数据更改时。然后,为了刷新数据,我使用selectquery。然后我将其保存在当前会话中。但是,这些更改只发生在更新和选择查询显示的页面中。我有一些网页,其中包括像顶栏,左导航。只有在刷新页面时才会更改。我的代码如下

<?php

     if(isset($_POST['update'])) {
        $name_t = $_POST['name'];
        $email_t = $_POST['email'];
        $pass_t = $_POST['password'];
        $contact_t = $_POST['contact'];
        $address_t = $_POST['address'];
        $dob_t = $_POST['dob'];
        $religion_t = $_POST['religion'];
        $pic_t = ($_FILES['imagefile']['name']);
        $sql = "
UPDATE teacher 
   SET t_name = '$name_t'
      , t_email = '$email_t'
      , t_password = '$pass_t'
      , t_phone = '$contact_t'
      , t_address = '$address_t'
      , t_dob = '$dob_t'
      , t_religion = '$religion_t' 
 where teacher_id='$update_id' 
";
        $retval = mysql_query($sql,$link);        
        if(! $retval ) {
           die('Could not update data: ' . mysql_error());
        }
      if (!empty($_FILES['imagefile']['name'])) {
      $sql = "UPDATE teacher SET t_photo = '$pic_t' where teacher_id='$update_id' ";
      $retval = mysql_query($sql,$link);
      $info = pathinfo($_FILES['imagefile']['name']);
      $ext = $info['extension']; // get the extension of the file
        $target = 'img/upload/'.$pic_t;
        move_uploaded_file( $_FILES['imagefile']['tmp_name'], $target);
    }
     }  
$result = mysql_query("SELECT * FROM teacher where teacher_id='$update_id' ",$link);
while($row = mysql_fetch_array($result)){
    $name = $row['t_name'];
    $email = $row['t_email'];
    $password = $row['t_password'];
    $contact = $row['t_phone'];
    $address = $row['t_address'];
    $dob = $row['t_dob'];
    $religion = $row['t_religion'];
    $img = WEB_URL . 'img/upload/'.$row['t_photo'];
    $_SESSION['objLogin'] = $row;
}
 mysql_close($link);
 ?>

在会话中使用的顶栏值中data@AslamPatel我以前就是这么做的,伙计。会话已正确更新。这个问题只是在页面重新加载或刷新时发生的。请注意,大约100年前,我们停止使用PHP的mysql_uuAPI,以及它曾经使用过的所有不好的东西associated@Strawberry谢谢你告诉我,伙计,我是新来的php和学习。你的意思是避免使用mysql而使用mysqli mate吗?如果是这样的话,我将遵循这个原则。或者PDO,关键是准备好的声明。