How to filter data rows from a table from php which is created after inner joined two tables in db

Viewed 23

This is the code I wrote, but it doesn't give values after I click the search button. I need to filter data from an existing table in the front end which has been created by inner joining two tables in the db.

         <form action="" method="Get" class="form-inline">
          <div class="col-xs-3">
           <input type="text" name="search" value="<?php if(isset($_GET['search'])){echo $_GET['search'];} ?>" class="form-control" placeholder="Filter Payments">
         </div>
         <div  class=" col-xs-2">
            <button type="submit" class="btn btn-primary">Search</button>
        </div>
        </form>
<?php 
$i=0;

if(isset($_GET['search']))
{
$filtervalues = $_GET['search'];
$get_query = "select * from product 
              inner join pending_orders
              ON product.product_id = pending_orders.product_id
              inner join customer_orders
             ON customer_orders.order_id = pending_orders.order_id  
            where pending_orders.order_status='Cash On Delivery -Done'                        CONCAT('invoice_no','due_amount','order_date','qty','order_status','product_title') LIKE '%$filtervalues%' ";
                           
  $run_query = mysqli_query($con,$get_query);

  if(mysqli_num_rows($run_query) > 0)
      {
                                
         while($row_query=mysqli_fetch_array($run_query)){
                            
            $invoice_no = $row_query['invoice_no'];
                                    
            $amount = $row_query['due_amount'];
                                    
            $date = $row_query['order_date'];

            $qty = $row_query['qty'];
                                    
            $order_status = $row_query['order_status'];
                             
            $product_title = $row_query['product_title'];
                                    
            $i++;
    ?>
                                   
            <tr> <!-- tr begin -->
            <td> <?php echo $i; ?> </td>
           <td> <?php echo $invoice_no; ?> </td>
          <td> <?php echo $product_title; ?> </td>
           <td> <?php echo $qty; ?></td>
           <td> <?php echo $amount; ?></td>
         <td> <?php echo $date; ?> </td>
                                
          </tr>
<?php
                                }                          
   }

  else 
   {
      ?>
         <tr>
         <td clospan="6">No Records Found</td>
       </tr>
<?php
    }
    }
  ?>
0 Answers
Related