2014-01-10 4 views
0

app.php가 다른 페이지에서 값을 가져 오는 중입니다. 그리고이 값은 쿼리 목적으로 사용됩니다. 이 값은 app.php에서 여러 값을 편집하는 데 사용됩니다. edit.php에 여러 값을 다시 게시하여 app.php에 표시된 레코드를 업데이트합니다. 내가 원하는 것은 <meta http-equiv="refresh" content="0;app.php" /> 또는 <script type="text/javascript">window.history.go(-1);</script>을 사용하여 app.php로 돌아갈 때 app.php의 값이 edit.php의 새 값이나 업데이트 된 값을 가져야한다는 것입니다. 나는 세션을 사용하여 좋지 않다. 도와주세요? 당신이 이전 데이터를 유지할 수있는 페이지를 반환하는 자바 스크립트를 사용하는 경우세션 값을 변경하는 방법

app.php

$mysqli = new mysqli("localhost", "root", "", "app"); 
ob_start(); 
session_start() 

<form name="myform" method="post" action="edit.php"/> 
if (isset($_POST['submit'])) { 

    //unset the session value 
    $_SESSION['content'] = ''; 

    $drop  = $_POST['drop_1']; 
    $tier_two = $_POST['tier_two']; 

    $where = "WHERE a.app_cn='$drop' AND a.app_plan_no='$tier_two'"; 

    $result1 = $mysqli->query(" query "); 

<table> 
while ($row = $result1->fetch_assoc()) { 
<td><input name="checkbox[]" type="checkbox" id="checkbox[]" value="' . $row['id'] . '"'.($row['pr'] == ""?"disabled ":"").' style="cursor:pointer;" class="checkbox"></td> 
} 
</table> 

$sPageContent  = ob_get_clean(); 
    $_SESSION['content'] = $sPageContent; 
     echo $_SESSION['content']; 
} else { 
    if (isset($_SESSION['content'])) { 
     echo $_SESSION['content']; 
    } 
} 
</form> 

Edit.php

<?php 
$mysqli = new mysqli("localhost", "root", "", "app"); 
if (isset($_POST['submit'])) { 
$counter=$_POST['counter']; 
$pr=$_POST['pr']; 
$pr_qty=$_POST['pr_qty']; 
$N = count($counter); 
for($i=0; $i < $N; $i++) 
{ 
    $result = $mysqli->query("UPDATE purchase_request SET pr='$pr[$i]', total_quantity='$pr_qty[$i]' where counter='$counter[$i]'"); 
} 
    echo'<meta http-equiv="refresh" content="0;app.php" />'; 
} 

?> 

<form class="form-horizontal" action="" method="post">  
<?php 
$id=$_POST['checkbox']; 
$N = count($id); 
for($i=0; $i < $N; $i++) 
{ 
    $result1 = $mysqli->query(" 
SELECT a.item_name, a.item_description, a.counter, b.counter, b.pr, b.total_quantity 
FROM app a 
LEFT OUTER JOIN purchase_request b 
ON a.counter=b.counter 
WHERE a.counter='$id[$i]' 
    "); 
    while ($row = $result1->fetch_assoc()) 
     { ?> 
<input name="item_name[]" class="textbox" type="text" value="<?php echo $row['item_name'] ?>"/> 
<input name="item_description[]" class="textbox" type="text" value="<?php echo $row['item_description'] ?>"/> 
<input name="pr_qty[]" id="pr_qty[]" class="textbox tb1" type="text" value="<?php echo $row['total_quantity']; ?>" /> 
<input name="pr[]" class="textbox" type="text" value="<?php echo $row['pr'] ?>" /> 
?> 
<input name="submit" type="submit" id="sbtBtn" value="Update"> 
</form> 
+0

하지만 난 이해할 수 없다 :(나는 프레드-II @ 세션 – user3097736

+0

를 사용하여 힘든 시간을 보내고있어 - 알았어, 팁 좀 줘. 내가 app.php에서 세션을 바꿀 수 있도록 edit.php의 가치를 얻는 방법 – user3097736

+0

@ Fred-ii- 나는 지옥에있다. :( – user3097736

답변

0

대신 <meta http-equiv="refresh" content="0;app.php" />

header('Location: app.php')를 사용하여. 우리 브라우저에 캐시가 있기 때문입니다. 당신은 캐시를 사용하지 <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"><META HTTP-EQUIV="EXPIRES" CONTENT="Mon, 22 Jul 2002 11:12:01 GMT"> 을 사용할 수 있습니다

프레드-II-좋은 대답 @
+0

나는 그것을 시도했지만 작동하지 않습니다 : ( – user3097736

관련 문제