www.webdeveloper.com
Results 1 to 6 of 6

Thread: Export Excel using php its working in localhost but not working in Server?

Hybrid View

  1. #1
    Join Date
    Oct 2012
    Posts
    8

    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: &nbsp;<?php echo $month; ?>&nbsp;-&nbsp;<?php echo $year; ?>&nbsp;&nbsp;&nbsp;&nbsp;Branch:&nbsp;&nbsp;<?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="javascriptrint()">Print Page</a>&nbsp;*&nbsp;<a href="javascript:void(0);" onClick="download();" >Download Excel Report</a></h3>
    </div>
    </form>
    </body>
    </html>

  2. #2
    Join Date
    Mar 2009
    Posts
    452
    mani can u plz provide the link on your server.

    also make sure you have uploaded excelwriter.calss.php and configured mysql database properly.

    also to find out errors, add error_reporting(E_ALL); just before session_start();

  3. #3
    Join Date
    Oct 2012
    Posts
    8

    Post EXPORT EXCEL USING PHP with JQUERY

    thanks for reply ZABI,

    I found another way to export excel report using php with jquery. My code is..
    <?php
    session_start();
    if(!isset($_SESSION['branch']))
    {
    header("location:logout.php");
    }
    include('db.php');


    error_reporting(0);
    // GET FROM Employee Report.php
    $branch=$_REQUEST['branch'];
    $designation=$_REQUEST['designation'];

    ?>

    <html><head><title>JAI SAIRAM ASSOCIATES</title>

    <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script>
    <style type="text/css">
    .myClass
    {
    font-family:verdana;
    font-size:11px;
    }
    </style> </script>


    </head><body alink="#2046EE" link="#2046EE">

    <form name="employee_reportview" action="exporttoexcel.php" method="post" enctype="multipart/form-data" onsubmit='$("#datatodisplay").val( $("<div>").append( $("#ReportTable").eq(0).clone() ).html() )'>
    <center>
    <font face="Arial, Helvetica, sans-serif" size="2"><?php /*
    <h1>JAI SAIRAM ASSOCIATES</h1>
    <h2>Employee Report</h2>
    <h4>&nbsp; &nbsp; &nbsp;&nbsp;Branch: &nbsp; &nbsp;<?php echo $branch; ?></h4>
    </font> */?>
    </center>

    <?php
    /* Fetch Using BRANCH */

    if(isset($_REQUEST['branch'])){
    ?>
    <table align="center">
    <tr><td align="center"><h1>JAISAIRAM ASSOCIATES</h1></td></tr>
    <tr><td align="center"><h2>Employee Report</h2></td></tr>
    <tr><td align="center"><h4>Branch:<?php echo $branch;?></h4></td></tr>
    <tr>
    <td><input type="button" onClick="mani()" value="PDF">
    <table width="98%"border="1" align="center" cellpadding="3" cellspacing="0" bgcolor="#FFFFFF" id="ReportTable">
    <tr bgcolor="#FFFFFF">
    <th><font>EmployeeID</font></th>
    <th><font>Name</font></th>
    <th><font>Branch</font></th>
    <th><font>Designation</font></th>
    <th><font>Gender</font></th>
    <th><font>DOB</font></th>
    <th><font>DOJ</font></th>
    <th><font>PersonalNo</font></th>
    <th><font>OfficialNo</font></th>
    <th><font>Address</font></th>
    <th><font>Email</font></th>
    <th><font>Referredby</font></th>
    <th><font>ReferbyNo</font></th>
    <th>Image</th>
    </tr>
    <?php
    $searchSQL = "SELECT emp_id,name,gender,dob,doj,personal_mobile,official_mobile,perm_address,official_email,branch,design ation,referredby,referno,photo FROM employee WHERE branch='$_POST[branch]' AND designation='$designation'";
    $select_name = mysql_query($searchSQL)or die ("Query failed: " . mysql_error() . " Actual query: " . $select_name);
    $count = mysql_num_rows($select_name);
    if($count> 0){
    while($sel_row = mysql_fetch_array($select_name)){
    // INSERT THE ARRRAY VALUE
    $dob=date('d-m-Y',strtotime($sel_row['dob']));
    $doj=date('d-m-Y',strtotime($sel_row['doj']));
    $photo=$sel_row['photo'];
    ?>
    <tr>
    <td align="center"><?php echo $sel_row['emp_id']; ?></td>
    <td align="center"><?php echo $sel_row['name']; ?></td>
    <td align="center"><?php echo $sel_row['branch']; ?></td>
    <td align="center"><?php echo $sel_row['designation']; ?></td>
    <td align="center"><?php echo $sel_row['gender']; ?></td>
    <td align="center"><?php echo date('d-m-Y',strtotime($sel_row['dob'])); ?></td>
    <td align="center"><?php echo date('d-m-Y',strtotime($sel_row['doj'])); ?></td>
    <td align="center"><?php echo $sel_row['personal_mobile']; ?></td>
    <td align="center"><?php echo $sel_row['official_mobile']; ?></td>
    <td align="center"><?php echo $sel_row['perm_address']; ?></td>
    <td align="center"><?php echo $sel_row['official_email']; ?></td>
    <td align="center"><?php echo $sel_row['referredby']; ?></td>
    <td align="center"><?php echo $sel_row['referno']; ?></td>

    <?php ?>
    <td align="center"><?php echo '<img src="data:image/jpeg/jpg/bmb;base64,' . base64_encode( $photo ) . '" width="50" height="50" />'; ?></td>


    </tr>
    <?php }
    }else {
    ?><tr><td height="20" colspan="20" align="center">No Records Found</td>
    </tr>
    <?php
    }
    }
    ?></table><br></td></tr></table>
    <br>

    <div align="right"><h3><a href="#" a onClick="javascriptrint()"><input type="button" value="PRINT"></a>&nbsp;*&nbsp;<input type="hidden" id="datatodisplay" name="datatodisplay"><input type="submit" value="EXCEL"><input type="hidden" value="<?php echo $branch;?>" name="branch"><input type="hidden" name="desing" value="<?php echo $designation; ?>"><a href="pdfexport.php?branch=<?php echo $branch;?> &desing=<?php echo $designation; ?>" >PDF</a></div>
    <?php

    ?>



    </form></body></html>
    <?php inlcude('footer.php'); ?>

  4. #4
    Join Date
    Oct 2012
    Posts
    8
    thanks for reply ZABI,

    I already uploaded excelwriter.calss.php and also configured mysql db properly. but its working in local not in server.. so i change my code to take clone of the table using jquery. This way give good result for me
    if i put error_reporting(E_ALL); Just before seesion_start()- its show on warning in that page. thanks ZABI. Here i want export PDF with image and db data .. I want YOUR HELP.. Plz Help me...

  5. #5
    Join Date
    Mar 2009
    Posts
    452
    actually that we need that warning message about error to figure it out. for exporting data to PDF there are couple of libraries; you can search on net.

  6. #6
    Join Date
    Oct 2012
    Posts
    8
    thanks ZABI I will try with fpdf.

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
  •  
HTML5 Development Center

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.12944 seconds
  • Memory Usage 3,084KB
  • Queries Executed 13 (?)
More Information
Template Usage (29):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (6)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (27):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./includes/functions_threadedmode.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (72):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates