<?php  
include 'connect.php';
$output = '';
if(isset($_POST["export"]))
{
 $query = "SELECT * FROM order_details";
 $result = mysqli_query($conn, $query);
 if(mysqli_num_rows($result) > 0)
 {
  $output .= '
   <table class="table" bordered="1"> <tr> <th>MAIN BILLING NO</th> <th>ORDER TYPE</th> <th>ORDER NO</th> <th>DATE/TIME</th> <th>PORTING</th> <th>SWITCH PREFIX</th> <th>LCP</th> <th>LCPCUPID</th> <th>RH</th> <th>RH CUPID</th> <th>PORT DATE</th> <th>PORT TIME</th> <th>ASSOCIATED NUMBER</th> <th>POST CODE</th> <th>DDI START</th> <th>DDI END</th> <th>NOTE</th> </tr>
  ';
  while($row = mysqli_fetch_array($result))
  {
   $output .= '
    <tr> <td>'.$row["bill_no"].'</td> <td>'.$row["order_type"].'</td> <td>'.$row["orderno"].'</td> <td>'.$row["date"].'</td> <td>'.$row["porting"].'</td> <td>'.$row["prefix"].'</td> <td>'.$row["lcp"].'</td> <td>'.$row["lcp_cupid"].'</td> <td>'.$row["rh"].'</td> <td>'.$row["rh_cupid"].'</td> <td>'.$row["port_date"].'</td> <td>'.$row["port_time"].'</td> <td>'.$row["asso_no"].'</td> <td>'.$row["post_code"].'</td> <td>'.$row["start"].'</td> <td>'.$row["end"].'</td> <td>'.$row["note"].'</td> </tr>
   ';
  }
  $output .= '</table>';
    header("Content-type: application/vnd.ms-excel; name='excel'");
    header("Content-Disposition: attachment; filename=exportfile.xls");
    header("Pragma: no-cache");
    header("Expires: 0");
  echo $output;
 }
}
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.