Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.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 提交表单更新MySQL行后页面未刷新_Php_Mysql_Caching_Meta Tags - Fatal编程技术网

Php 提交表单更新MySQL行后页面未刷新

Php 提交表单更新MySQL行后页面未刷新,php,mysql,caching,meta-tags,Php,Mysql,Caching,Meta Tags,当我使用FormoverPHP页面更新Mysql表时,当我点击submit时,页面不会自动刷新。我必须点击刷新来查看更新的行。 我试过了,但这也没用。有什么好主意吗 <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"> <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> ///////////////////////Edited Bottom///////////////////

当我使用FormoverPHP页面更新Mysql表时,当我点击submit时,页面不会自动刷新。我必须点击刷新来查看更新的行。 我试过了,但这也没用。有什么好主意吗

<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">

///////////////////////Edited Bottom////////////////////////////////////////////////////////

<?php

include ("../header.php");
include ("../header2.php");

?>
<?php
include('../config.php');
include ('../ac.thumbs.php');

 if ($_GET['sil']) {
    $sil = htmlspecialchars(stripslashes($_GET['sil']));
    mysql_query("DELETE FROM CloseOut WHERE itemNO = $sil limit 1");
    echo "<h1>$sil item nolu kayit silinmistir</h1><br>";
}

    $edit = htmlspecialchars(stripslashes($_GET['edit']));
 $data = mysql_query("SELECT * FROM CloseOut WHERE itemNO=$edit") or die(mysql_error()); 

 //Puts it into an array 
 while($info = mysql_fetch_array( $data )) 
 { echo "
<center>
<a href=\"edit.php?sil=$info[itemNO]\"onclick=\"return confirm('Do you really want to erase this entry?')\">[ Delete ]</a><br>
<a href=../../large.php?f=upload/".$info['resim'], $thumblarge .">
<img src=../../small.php?f=upload/".$info['resim'], $thumbsmall .">
</a>";
$editresim = $info[resim];
$editisim = $info[isim];
$editalan1 = $info[alan1];
$editalan2 = $info[alan2];
$editalan3 = $info[alan3];
$editalan4 = $info[alan4];
} 

 //Resimlerin yuklenecegin yer
 $target = "../../upload/";  
 //////////////////////////////////////////////////////////////////////
 ///////////////////////////////Resim1/////////////////////////////////
 //////////////////////////////////////////////////////////////////////
 $target1 = $target . basename( $_FILES['resim1']['name']) ; 
 //Formdan gelen bilgileri almasi icin
 $resim=($_FILES['resim1']['name']); 
 $isim=$_POST['isim1']; 
 $alan1=$_POST['alan11']; 
 $alan2=$_POST['alan21']; 
 $alan3=$_POST['alan31']; 
 $alan4=$_POST['alan41']; 



/////////////Formdaki bos alanlara bos bilgi kayit etmemesi icin////////////////////////

$updates = array();
if (!empty($resim))
  $updates[] = 'resim="'.mysql_real_escape_string($resim).'"';
if (!empty($isim))
  $updates[] = 'isim="'.mysql_real_escape_string($isim).'"';
if (!empty($alan1))
  $updates[] = 'alan1="'.mysql_real_escape_string($alan1).'"';
if (!empty($alan2))
  $updates[] = 'alan2="'.mysql_real_escape_string($alan2).'"';
if (!empty($alan3))
  $updates[] = 'alan3="'.mysql_real_escape_string($alan3).'"';
if (!empty($alan4))
  $updates[] = 'alan4="'.mysql_real_escape_string($alan4).'"';
$updates = implode(', ', $updates);


/////////////////////////////////////////////////////////////////////////////////////////
 //update etmesi icin
if(move_uploaded_file($_FILES['resim1']['tmp_name'], $target1)) 
{   
mysql_query("UPDATE CloseOut SET $updates WHERE itemNO='$edit' ");
echo "Tebrikler, ". basename( $_FILES['resim1']['name']). " isimli dosya yuklendi ve database'e basariyla islendi!<br>"; 
 } 




?>

<br>
<center> 
<table width="900" border="5" style="background-color:white; "bordercolor="#000000">
    <tr>
        <td width="120" height="50" bgcolor= "545454"><b>RESIM</b></td>
        <td width="120" height="50" bgcolor= "545454"><b>NAME</b></td>
        <td width="120" height="50" bgcolor= "545454"><b>CATAGORY</b></td>
        <td width="120" height="50" bgcolor= "545454"><b>QUANTITY</b></td>
        <td width="120" height="50" bgcolor= "545454"><b>LOCATION</b></td>
        <td width="120" height="50" bgcolor= "545454"><b>PRICE</b></td>
    </tr>
    <tr>
<form enctype="multipart/form-data" method="post" action="">
<td><input type="file" name="resim1" value="<?php echo $editresim;?>"> </td>
<td><input type="text" name="isim1" value="<?php echo $editisim;?>"> </td>
<td><input type="text" name="alan11" value="<?php echo $editalan1;?>"> </td>
<td><input type="text" name="alan21" value="<?php echo $editalan2;?>">  </td>
<td><input type="text" name="alan31" value="<?php echo $editalan3;?>"></td>
<td><input type="text" name="alan41" value="<?php echo $editalan4;?>"></td>
</tr>

<td colspan="6"><center><input type="submit"></center></td>


</form>
</table>
</center>

///////////////////////编辑底部////////////////////////////////////////////////////////

你现在能看到吗
$editresm
值为
$info[resim]

提交表单时,
$info[resim]
是当前的数据库值。数据库更新如下/之后

提交时,在提交的值实际放入数据库之前,您仍将看到以前的数据。因此,您需要重新打开该页面以查看更新的数据

解决此问题的一种方法是,您应该将更新数据的代码移至顶部,然后再
从收尾中选择*FROM CloseOut WHERE itemNO=$edit
,这样查询将为您提供最新/更新的数据

很抱歉没有提供示例代码,但恐怕我会犯一些小错误,这会增加混乱。事实上,如果你自己解决它会更好

祝你好运

附言:你的逻辑

Get data from db

Put to data to VAR

If form is submitted:

    Update data in DB

Show VAR // This is *not* the latest submitted data

问题是,您在获得信息后更新数据库

把这部分代码

//Resimlerin yuklenecegin yer
 $target = "../../upload/";  
 //////////////////////////////////////////////////////////////////////
 ///////////////////////////////Resim1/////////////////////////////////
 //////////////////////////////////////////////////////////////////////
 $target1 = $target . basename( $_FILES['resim1']['name']) ; 
 //Formdan gelen bilgileri almasi icin
 $resim=($_FILES['resim1']['name']); 
 $isim=$_POST['isim1']; 
 $alan1=$_POST['alan11']; 
 $alan2=$_POST['alan21']; 
 $alan3=$_POST['alan31']; 
 $alan4=$_POST['alan41']; 



/////////////Formdaki bos alanlara bos bilgi kayit etmemesi icin////////////////////////

$updates = array();
if (!empty($resim))
  $updates[] = 'resim="'.mysql_real_escape_string($resim).'"';
if (!empty($isim))
  $updates[] = 'isim="'.mysql_real_escape_string($isim).'"';
if (!empty($alan1))
  $updates[] = 'alan1="'.mysql_real_escape_string($alan1).'"';
if (!empty($alan2))
  $updates[] = 'alan2="'.mysql_real_escape_string($alan2).'"';
if (!empty($alan3))
  $updates[] = 'alan3="'.mysql_real_escape_string($alan3).'"';
if (!empty($alan4))
  $updates[] = 'alan4="'.mysql_real_escape_string($alan4).'"';
$updates = implode(', ', $updates);


/////////////////////////////////////////////////////////////////////////////////////////
 //update etmesi icin
if(move_uploaded_file($_FILES['resim1']['tmp_name'], $target1)) 
{   
mysql_query("UPDATE CloseOut SET $updates WHERE itemNO='$edit' ");
echo "Tebrikler, ". basename( $_FILES['resim1']['name']). " isimli dosya yuklendi ve database'e basariyla islendi!<br>"; 
 } 

听起来你的表单有问题。你能用表单结构粘贴代码吗?是的。我们可以查看表单吗?在同一页面上更新后是否重定向?请查看表单中的帖子。你可能没有在这里给出脚本的名称。谢谢你的回答+1,但是我没有足够的代表
$edit = htmlspecialchars(stripslashes($_GET['edit']));