0

I have a quote table that people insert basic information, such as name, product type etc. Which is all fine.

The admin can see the quote table and has a button to view the information in a structured manner.

Now what i have been trying to do is add a button called "Accept" and "Deny" which would move the table entry to the Denied or accepted table (same structure as the quote table)

I have looked around on google but only found assistance in making a button to delete entries or add new entries.

Below is the admin quote viewing page code with the view button:

<?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>
RedZ
  • 408
  • 1
  • 8
  • 25

1 Answers1

1

Have you considered a different approach? If the two tables have the exact same structure, then all you need is a single table and add a column called 'accepted' and use 1 and 0 values to act as true and false.

Then you can search this single table WHERE 'accepted' = 1 for accepted entries, or 0 for denied entries. And to change an entry's status, simply update a single column. Much easier.

Example:

$result = mysqli_query("SELECT * FROM tableName WHERE accepted = 1");

That will get only entries you have marked as accepted. Change it to WHERE accepted = 0" to get the denied entries.

And here is how you can allow the admin to change an entry's accepted/denied status easily:

$update = mysqli_query("UPDATE tableName SET accepted = 1 WHERE id = 12345");

By the way, I suggest you use mysqli instead of mysql, heres a good answer why.

Jay A. Little
  • 3,239
  • 2
  • 11
  • 32
  • that sounds good Jay where would i add the Where 'accepted' = 1? – RedZ Dec 10 '17 at 16:54
  • At the end of any of your MYSQL strings. Whenever you need to get only accepted entries or denied entries. Or whenever you need to make sure that the entry is one or the other. I'll add an example to my answer... – Jay A. Little Dec 10 '17 at 17:03
  • That is all well but i still require a button on the quote table to set the value to 1 or 0 as when the user submits the quote, the admin must accept or decline – RedZ Dec 10 '17 at 17:48
  • I see. Well just like you have the View Button, you can make an Accept Button, and Deny Button. Those could lead to a simple PHP file that updates the database table. Just like you handle the View Button, pass the id in the url. ` <--ACCEPT BUTTON` Then inside 'quote-handler.php' or whatever you name it, use $_GET['id'] and check if $_GET['accept'] == 'true' to then update the database. For the deny button, just change the url parameter &accept=false. – Jay A. Little Dec 10 '17 at 18:02