Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.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 - Fatal编程技术网

Php 将一个表条目移动到另一个表

Php 将一个表条目移动到另一个表,php,Php,我有一个报价表,人们插入的基本信息,如名称,产品类型等,这是所有的罚款 管理员可以查看报价表,并有一个按钮以结构化方式查看信息 现在,我一直在尝试添加一个名为Accept和Deny的按钮,它将表条目移动到Denied或accepted表中,该表的结构与quote表相同 我已经在谷歌上搜索过了,但只找到了一个按钮来删除条目或添加新条目的帮助 以下是“查看”按钮的管理员报价查看页面代码: <?php session_start(); include("dbconnection.php"); i

我有一个报价表,人们插入的基本信息,如名称,产品类型等,这是所有的罚款

管理员可以查看报价表,并有一个按钮以结构化方式查看信息

现在,我一直在尝试添加一个名为Accept和Deny的按钮,它将表条目移动到Denied或accepted表中,该表的结构与quote表相同

我已经在谷歌上搜索过了,但只找到了一个按钮来删除条目或添加新条目的帮助

以下是“查看”按钮的管理员报价查看页面代码:

<?php
session_start();
include("dbconnection.php");
include("checklogin.php");
check_login();
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<meta charset="utf-8" />
<title>Admin | Manage Logged Claims</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta content="" name="description" />
<meta content="" name="author" />
<link href="assets/plugins/bootstrap-select2/select2.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="assets/plugins/jquery-datatable/css/jquery.dataTables.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/datatables-responsive/css/datatables.responsive.css" 
rel="stylesheet" type="text/css" media="screen"/>
<link href="assets/plugins/boostrapv3/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/boostrapv3/css/bootstrap-theme.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/animate.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/jquery-scrollbar/jquery.scrollbar.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/style.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/responsive.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/custom-icon-set.css" rel="stylesheet" type="text/css"/>
</head>
<body class="">
<?php include("header.php");?>
<div class="page-container row"> 

  <?php include("leftbar.php");?>

  <div class="clearfix"></div>
  <!-- END SIDEBAR MENU -->
</div>
</div>
<div class="page-content">
<!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->
<div id="portlet-config" class="modal hide">
  <div class="modal-header">
    <button data-dismiss="modal" class="close" type="button"></button>
    <h3>Widget Settings</h3>
  </div>
  <div class="modal-body"> Widget settings form goes here </div>
</div>
<div class="clearfix"></div>
<div class="content">
  <ul class="breadcrumb">
    <li>
      <p>YOU ARE HERE</p>
    </li>
    <li><a href="#" class="active">Claims Logged</a> </li>
  </ul>
  <div class="page-title"> <i class="icon-custom-left"></i>
    <h3>Manage Logged Claims</h3>
  </div>
  <div class="row-fluid">
    <div class="span12">
      <div class="grid simple ">
        <div class="grid-title">
          <h4>Table <span class="semi-bold">Styles</span></h4>
          <div class="tools"> <a href="javascript:;" class="collapse"></a> 
<a href="#grid-config" data-toggle="modal" class="config"></a> <a href="javascript:;" class="reload"></a> <a href="javascript:;" class="remove">
</a> </div>
        </div>
        <div class="grid-body ">
          <table class="table table-hover table-condensed" id="example">
            <thead>
              <tr>
                <th style="width:1%">#</th>
                <th style="width:10%">Name</th>
                <th style="width:10%" data-hide="phone,tablet">Email</th>
                <th style="width:10%">Contact no</th>
                <th style="width:20%" data-hide="phone,tablet">Claim Requested</th>
                <th style="width:10%">Action </th>
              </tr>
            </thead>
            <tbody>
            <?php $ret=mysql_query("select * from prequest order by id desc");
            $cnt=1;
            while($row=mysql_fetch_array($ret))
            {?>
              <tr >
                <td class="v-align-middle"><?php echo $cnt;?></td>
                <td class="v-align-middle"><?php echo $row['name'];?></td>
                <td class="v-align-middle"><span class="muted"><?php echo $row['email'];?></span></td>
                <td><span class="muted"><?php echo $row['contactno'];?>
</span></td>
                <td class="v-align-middle"><?php echo $row['wdd'];?>
                <?php echo $row['cms'];?>
                <?php echo $row['seo'];?>
                <?php echo $row['smo'];?>
                <?php echo $row['swd'];?>
                <?php echo $row['dwd'];?>
                <?php echo $row['fwd'];?>
                <?php echo $row['dr'];?>
                <?php echo $row['whs'];?>
                <?php echo $row['wm'];?>
                <?php echo $row['ed'];?>
                <?php echo $row['wta'];?>
                <?php echo $row['opi'];?>
                <?php echo $row['ld'];?>
                <?php echo $row['da'];?>
                    <?php echo $row['osc'];?>
                        <?php echo $row['nd'];?>
                            <?php echo $row['others'];?>
                </td>
                  <td><a href="quote-details.php?id=<?php echo $row['id'];?>"><button class="btn-danger-dark">View</button></a></td> <--VIEW BUTTON
              </tr>
             <?php $cnt=$cnt+1; } ?>
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
 </div>

<div class="addNewRow"></div>
</div>

</div>
<script src="assets/plugins/jquery-1.8.3.min.js" type="text/javascript">
</script>
<script src="assets/plugins/jquery-ui/jquery-ui-1.10.1.custom.min.js" type="text/javascript"></script>
<script src="assets/plugins/boostrapv3/js/bootstrap.min.js" type="text/javascript"></script>
<script src="assets/plugins/breakpoints.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-unveil/jquery.unveil.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-scrollbar/jquery.scrollbar.min.js" type="text/javascript"></script>    
<script src="assets/plugins/jquery-block-ui/jqueryblockui.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-numberAnimate/jquery.animateNumbers.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrap-select2/select2.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-datatable/js/jquery.dataTables.min.js" type="text/javascript" ></script>
<script src="assets/plugins/jquery-datatable/extra/js/dataTables.tableTools.min.js" type="text/javascript" >
</script>
<script type="text/javascript" src="assets/plugins/datatables-responsive/js/datatables.responsive.js"></script>
<script type="text/javascript" src="assets/plugins/datatables-responsive/js/lodash.min.js"></script>
 <script src="assets/js/datatables.js" type="text/javascript"></script>
 <script src="assets/js/core.js" type="text/javascript"></script>
 <script src="assets/js/chat.js" type="text/javascript"></script>
 <script src="assets/js/demo.js" type="text/javascript"></script>
 </body>
 </html>

你考虑过不同的方法吗? 如果这两个表具有完全相同的结构,那么您只需要一个表并添加一个名为“accepted”的列,然后使用1和0值作为true和false

然后,您可以在“accepted”=1的单个表中搜索接受的条目,或在0中搜索拒绝的条目。要更改条目的状态,只需更新一列即可。容易多了

例如:

$result=mysqli\u querySELECT*FROM tableName,其中accepted=1

这将只获取您标记为已接受的条目。 将其更改为WHERE accepted=0以获取被拒绝的条目

下面是允许管理员轻松更改条目的接受/拒绝状态的方法:

$update=mysqli\u queryUPDATE tableName SET accepted=1,其中id=12345


顺便说一下,我建议您使用mysqli而不是mysql,。

这是糟糕的数据库设计。您应该在表中添加一个字段,其中包含accepted、denied等的值。这听起来不错,我应该在任何MYSQL字符串的末尾添加where'accepted'=1。只要您需要只获取接受的条目或拒绝的条目。或者当您需要确保条目是一个或另一个时。我将在我的答案中添加一个示例…这很好,但我仍然需要quote表上的一个按钮将值设置为1或0,因为当用户提交quote时,管理员必须接受或取消我看到的。就像你有查看按钮一样,你可以做一个接受按钮和拒绝按钮。这些可能会生成一个简单的PHP文件来更新数据库表。就像处理View按钮一样,在url中传递id。