简体   繁体   English

停留在同一页中使用PHP中的位置标头

[英]staying in same page using location header in php

I have table which are going in different pages and all row have one attribute which is button and button is used for deleting row from table and when button function performed , it is going in header action , but when it is performed in second page after completing action header is sending it in first page , i want it should stay in same page. 我有要在不同页面中移动的表,并且所有行都有一个属性,即button和button用于从表中删除行,并且当执行button函数时,它将进入页眉操作,但是当完成后在第二页中执行时操作标头将其发送到第一页,我希望它应该保留在同一页中。 How can i do this? 我怎样才能做到这一点?

Here is some code 这是一些代码

<?php
if(isset($_GET['index_edit_id']))
{
    $delete_id=$_GET['index_edit_id'];
    $sql = "DELETE FROM update_table WHERE  id='$delete_id';UPDATE files SET show_status=null  WHERE id='$delete_id';DELETE FROM callcase WHERE id='$delete_id';DELETE FROM lettercase WHERE id='$delete_id'";
    $run=mysqli_multi_query($con,$sql);
    header("location:index.php");
}
?>

I want to send location with pagination number and if it is with search key then it should also take all passable situation , should i store key and pagination number in session . 我想发送带有分页号的位置,如果它是带有搜索键的,那么它也应该考虑所有可通过的情况,如果我在会话中存储键和分页号。 Help me please 请帮帮我

You Question is not clear If you want to stay in the page where the code you showed is runing , just delete the last line : header("location:index.php"); 您的问题还不清楚如果您想停留在正在显示代码的页面中,只需删除最后一行:header(“ location:index.php”); if you want it to go back to the page that called replace this 如果您希望它返回到调用此页面的页面

header("location:index.php");

with this 有了这个

header("location:".$_SERVER['HTTP_REFERER']);

If you want to send some parametter , send it with url as id=5 Than replace the id in the header like this 如果要发送一些参数,请使用url作为id = 5发送,而不是像这样替换标头中的id

header("location:page.php?id=".$_GET['id'));

I hope this helped you. 希望这对您有所帮助。

As far as i understand you are using a single table instance which is accessed by multiple other html pages. 据我了解,您正在使用一个表实例,其他多个html页都可以访问该实例。 But what i suggest is you can use ajax function to perform delete operation and then you can just call a function to refresh the table alone 但是我建议您可以使用ajax函数执行删除操作,然后只需调用一个函数即可单独刷新表

bellow is my suggestion not the solution 下面是我的建议,不是解决方案

and here is the php code : 这是php代码:

<td><p>".$row['STATUS']."</p></td>
        <td><button class='btn btn-outline-danger' id='btn_Delete' onclick='onDelete()' value='".$row['ORDER_ID']."'><i class='fa fa-minus-circle' aria-hidden='true'></i>
 Delete</button>

the ajax code follows here Ajax代码如下

 var id = $("#btn_Delete").val();
    $.ajax({
            url: "your php link to delete",
            method: "your methios",
            data: {
                REFERENCE_ID: id,
            },
            success: function(result) {
                UIkit.notification({
                    message: result,
                    status: 'primary',
                    pos: 'top-right',
                    timeout: 5000
                });
                showTable();
            }
        })
        .done(function() {
            console.log("success");
        })
        .fail(function() {
            console.log("error");
        })
        .always(function() {
            console.log("complete");
        });

once done i have called the showtable() function which will automatically refresh the table in the html page without redirecting to another page 完成后,我调用了showtable()函数,该函数将自动刷新html页面中的表,而无需重定向到另一个页面

This might help you.. 这可能对您有帮助。

use javascript code for refresh page : 使用javascript代码刷新页面:

location.href += ""

or php location to current page 或PHP位置到当前页面

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM