heshan Posted August 12, 2011 Share Posted August 12, 2011 Hi all, I want to create daily reports using PHP. The below coidngs would result this error. ( ! ) Notice: Undefined index: date in C:\wamp\www\MySite\php files\tcpdf\examples\daily_transactions_report.php on line 16 $date = $_POST['date']; My transaction table looks like; transaction (tran_id, account_number, transaction_type, transaction_amount, transaction_date ) <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script src="datetimepicker_css.js"> </script> <script src="../../SpryAssets/SpryMenuBar.js" type="text/javascript"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <p><img src="../images/image 1.jpg" alt="" width="118" height="89" /> <img src="../images/logo-default.jpg" alt="" width="350" height="89" /> <img src="../images/image 2.jpg" alt="" width="100" height="89" /></p> <p> </p> <p> </p> <form id="form1" name="form1" method="post" action="daily_transactions_report.php"> <label>DailyTransaction Reports<br /> <br /> DATE </label> <input type="text" id="demo3" name="date" maxlength="25" size="25"/> <img src="../images/cal.gif" onclick="javascript:NewCssCal('demo3','yyyyMMdd')" style="cursor:pointer"/> <p> <label></label> <label> <a href="tcpdf/examples/daily_transactions_report.php"> <input type="submit" name="button" id="button" value="Generate" /> </a> </label> </p> </form> daily_transactions.php <?php require_once('../config/lang/eng.php'); require_once('../tcpdf.php'); // extend TCPF with custom functions class MYPDF extends TCPDF { public function myconnection(){ $this->con = mysql_connect("localhost","root",""); mysql_select_db("bank", $this->con); $date=''; $date = $_POST['date']; $this->result = mysql_query("SELECT * FROM transaction WHERE transaction_date = '".$date."' ORDER BY tran_id"); //if(!$this->result){ //echo mysql_error(); //} } // Colored table public function ColoredTable($header,$data) { // Colors, line width and bold font $this->SetFillColor(200, 128, 0); $this->SetTextColor(255); $this->SetDrawColor(128, 0, 0); $this->SetLineWidth(0.3); $this->SetFont('', 'B'); // Header $w = array(18, 15, 32, 22, 30, 45); $num_headers = count($header); for($i = 0; $i < $num_headers; ++$i) { $this->Cell($w[$i], 7, $header[$i], 1, 0, 'C', 1); } $this->Ln(); // Color and font restoration $this->SetFillColor(200, 200, 200); $this->SetTextColor(0); $this->SetFont(''); // Data $fill = 0; while($row1 = mysql_fetch_array($this->result)) { $this->Cell($w[0], 6, $row1['tran_id'], 0, 'L', $fill); $this->Cell($w[1], 6, number_format($row1['account_number']), 'LR', 0, 'R', $fill); $this->Cell($w[2], 6, $row1['transaction_type'], 'LR', 0, 'L', $fill); $this->Cell($w[3], 6, $row1['transaction_amount'], 'LR', 0, 'L', $fill); $this->Cell($w[4], 6, $row1['transaction_date'], 'LR', 0, 'L', $fill); $this->Cell($w[5], 6, $row1['approved_status'], 'LR', 0, 'L', $fill); $fill=!$fill; } $this->Cell(array_sum($w), 0, '', 'T'); } } // create new PDF document $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Mahapitiya Sanasa Bank'); $pdf->SetTitle('Daily Transaction Report'); $pdf->SetSubject(''); $pdf->SetKeywords(''); // set default header data //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 011', PDF_HEADER_STRING); // set header and footer fonts //$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); //$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); // --------------------------------------------------------- // set font $pdf->SetFont('times', 'BI', 7); // add a page $pdf->AddPage(); // set some text to print $txt = <<<EOD Mahapitiya Sanasa Bank, Mahapitiya, Pothuhera Tel:0372237295 Daily Transactions Report EOD; // print a block of text using Write() $pdf->Write($h=0, $txt, $link='', $fill=0, $align='C', $ln=true, $stretch=0, $firstline=false, $firstblock=false, $maxh=0); //Column titles $header = array('Tran ID', 'Account Number', 'Transaction Type', 'Transaction Amount', 'Transaction Date', 'Approved Status'); //Data loading //$data = $pdf->LoadData('../cache/table_data_demo.txt'); $pdf->myconnection(); // print colored table $pdf->ColoredTable($header,""); // --------------------------------------------------------- //Close and output PDF document $pdf->Output('example_011.pdf', 'I'); mysql_close($con); ?> //============================================================+ // END OF FILE //============================================================+ Link to comment https://forums.phpfreaks.com/topic/244566-errror-occurred-while-creating-reports/ Share on other sites More sharing options...
phpSensei Posted August 12, 2011 Share Posted August 12, 2011 edit: nvm. Have you tried var_dump($_POST) Link to comment https://forums.phpfreaks.com/topic/244566-errror-occurred-while-creating-reports/#findComment-1256205 Share on other sites More sharing options...
heshan Posted August 12, 2011 Author Share Posted August 12, 2011 I tried it. The same error occurs and "null"is also displayed with the error. Notice: Undefined index: date in C:\wamp\www\MySite\php files\tcpdf\examples\daily_transactions_report.php on line 16 null TCPDF ERROR: Some data has already been output, can't send PDF file Link to comment https://forums.phpfreaks.com/topic/244566-errror-occurred-while-creating-reports/#findComment-1256422 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.