Export Excel using php its working in localhost but not working in Server?
Hi, I am new for php developing, here i enclosed my export excel some data from db using php code its working in localhost well but after deploying server its not working ? this is my php code
<?php
session_start();
if(!isset($_SESSION['branch']))
{
header("location:logout.php");
}
include('db.php');
include('excelwriter.calss.php');
// GET FROM Monthly Overall Report.php
$branch=$_REQUEST['branch'];
$atoms = explode('-',$_REQUEST['month']);
$year = $atoms[1];
$month = $atoms[0];
$totalamt="";
$totalbal="";
?>
<html><head><title>JAI SAIRAM ASSOCIATES</title>
<script language="javascript">
function download()
{
window.location='report.xls';
}
</script>
</head>
<body alink="#2046EE" link="#2046EE">
</head>
<body>
<form name="monthly_customer_reportview" method="post" enctype="multipart/form-data">
<center>
<font face="Arial, Helvetica, sans-serif" size="2">
<h1>JAI SAIRAM ASSOCIATES</h1>
<h2>Monthly Customer Report</h2>
<h4>Month: <?php echo $month; ?> - <?php echo $year; ?> Branch: <?php echo $branch; ?></h4>
</font>
</center>
<?php
/* Fetch Using Branach And Month-Year */
if(isset($_REQUEST["month"])){
?>
<table align="center" width="98%" border="1" cellspacing="0" cellpadding="1" >
<tr><b>
<th>Name</th>
<th>Mobile</th>
<th>Policy</th>
<th>Branch</th>
<th>PolicyAmount</th>
<th>MedicalAmount</th>
<th>PaidAmount</th>
<th>Balance</th>
<th>Manager</th>
<th>Sales Rep</th>
<th>Telecaller</th>
</b>
</tr>
</tr>
<?php
$excel=new ExcelWriter("report.xls");
if($excel==false)
echo $excel->error;
$myArr=array("SNO","NAME","MOBILE","POLICY","BRANCH","TOTAL AMOUNT","MEDICAL AMOUNT","AMOUNT PAID","BALANCE","TO MANAGER","SALES REP","TELECALLER");
$excel->writeLine($myArr);
$sel_cust=mysql_query("SELECT a.name,a.cust_id,a.mobile,a.policy,a.branch,a.total_amount,a.telecaller,a.manager,a.sales_rep,a.medi cal_amount,b.amount_paid,
a.balance FROM customer_history a INNER JOIN (SELECT cust_id,SUM(installamt) as amount_paid FROM
customer_installment_history WHERE MONTHNAME(paid_date)='$month' AND year(paid_date)='$year' AND branch='$branch'
GROUP BY cust_id) b on a.cust_id=b.cust_id GROUP BY a.cust_id")or die("Query failed".mysql_error()."actual".$sel_cust);
$count = mysql_num_rows($sel_cust);
if($count> 0){
if($sel_cust!=false){ $i=1;
while($sel_row = mysql_fetch_array($sel_cust)){
$totalamt+=$sel_row['amount_paid'];
$totalbal+=$sel_row['balance'];
$myArr=array($i,$sel_row['name'],$sel_row['mobile'],$sel_row['policy'],$sel_row['branch'],$sel_row['total_amount'],$sel_row['medical_amount'],$sel_row['amount_paid'],$sel_row['balance'],$sel_row['manager'],$sel_row['sales_rep'],$sel_row['telecaller']);
$excel->writeLine($myArr);
$i++;
?>
<tr>
<td align="center"><?php echo $sel_row['name']; ?></td>
<td align="center"><?php echo $sel_row['mobile']; ?></td>
<td align="center"><?php echo $sel_row['policy']; ?></td>
<td align="center"><?php echo $sel_row['branch']; ?></td>
<td align="center"><?php echo $sel_row['total_amount']; ?></td>
<td align="center"><?php echo $sel_row['medical_amount']; ?></td>
<td align="center"><?php echo $sel_row['amount_paid']; ?></td>
<td align="center"><?php echo $sel_row['balance']; ?></td>
<td align="center"><?php echo $sel_row['manager']; ?></td>
<td align="center"><?php echo $sel_row['sales_rep']; ?></td>
<td align="center"><?php echo $sel_row['telecaller']; ?></td>
</tr>
<?php
}
}else{
?>
<tr><td colspan="11" align="center">No Records Found</td></tr>
<?php
} ?><tr><td colspan="11" align="center"><b>Total CollectionAmount:<?php echo $totalamt; ?>Total Balance:<?php echo $totalbal; ?></td></b></tr>
</table>
<?php } }?><br>
<div align="right"><h3><a href="#" a onClick="javascript rint()">Print Page</a> * <a href="javascript :void(0);" onClick="download();" >Download Excel Report</a></h3>
</div>
</form>
</body>
</html>
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks