PHP - Export To Pdf
Hi,
I have tried these PDF generators: 1. TCPDF- doesn't support css class. Styles will work if inline. 2. DOMPDF - Supports CSS class. Doesn't have Unicode support. Already tried load_font to convert ttf to amf but still Chinese char are not displayed properly. - Also tried (installed) PDFlib, watermark appears in pdf but characters are not displayed properly. Any suggestion in PDF generator that can do the functionality of TCPDF and DOMPDF? BTW i'm using xampp. Thanks in advance. Similar TutorialsDear freak gurus out there, I'm new to php and sql as i learn from online examples . Though there are lots of links and answers out there related to my post but none reflects what i need. You guys my only hope. What i have: 3 tables : each has its own number of fields (tbl1=14 ,tbl2=9,tbl3=9). There is a field in each tables that can be related (FamilyField). What i need: export to csv all the records from all 3 tables which relates to search criteria (by user) based on a field (MembershipField) which the data may vary from other tables. pseudo code: $membership_type =$_POST['mtype']; $sql=" SELECT field1,field2,field5,MembershipField from tbl1, (SELECT field1,field2,MembershipField from tbl2), (SELECT field3,field6,field8,MembershipField from tbl3) WHERE MembershipFied=$membership_type"; export to csv file by using INTO OUTFILE; I have tried all the code i can find to export from 1 table to csv, and i manage to use UNION to get output from 3 tables but unable to export as the error message was "incorrect usage of UNION and INTO. is this possible? or any workaround? guides with samples will be a great help. I need to write a cron job that will sync 2 databases. Is there a quick way to write an export from one database for import into another? Or do i manually have to write the select statements per table, format them as insert ignore strings, then execute them on the other database? Thanks guys! Hello, How can I export mysql database (tables) with php from browser to backup.sql , something like in phpMyAdmin. And simple option with file save as??? Thanks Regards Hi, Am having a total brain melt down on a php/mysql export script. I've a table wp_bp_xprofile_data with this sort of layout: ID field_id user_id value It shows data like so: id | field_id | user_id | value 1 | 1 | 1| John Smith 2 | 2 | 1 |john@smith.com 3 | 3 | 1 |23 arcacia avenue 4 | 1 | 2 |Fred Smith 5 | 2 | 2 |fred@smith.com 6 | 3 | 2 |999 lets be avenue field_id joins to another table wp_bp_xprofile_fields, where it has id name This shows data like so: id | name 1 | Name 2 | Email 3 | Address What I need to do, is export the data to a csv so the CSV will then show: Name | Email | Address John Smith | john@smith.com | 23 arcacia avenue Fred Smith | fred@smith.com | 999 lets be avenue However, mine keeps coming back Name | Email | Address John Smith john@smith.com 23 arcacia avenue Fred Smith fred@smith.com 999 lets be avenue Here's my code: [php] header ("Content-Disposition:\"inline; filename=export.csv"); header ("Content-type: text/csv\""); $query = "SELECT VALUE FROM `wp_bp_xprofile_data` ORDER BY `wp_bp_xprofile_data`.`user_id` ASC"; $result = mysql_query($query) or die("Query failed : " . mysql_error()); echo "email,telephone,county,town,add 2,add 1,company name,name,acc type,date joined,country\r\n"; //header while($row = mysql_fetch_row($result)){ echo "$row[0],$row[1],$row[2],$row[3],$row[4],$row[5],$row[6],$row[7],$row[8],$row[9],$row[10],$row[11]\r\n"; //data echo "$row[]\r\n"; //data } [php] Where am I going wrong? TIA I created this php class which recieves an sql query from flash and then produces a csv file for download. The code in its current form produces a csv file on the server. However, I want it to save on the client computer with a 'Save As' dialog box. I am testing on localhost. Here is the class: <?php class CSVExport { public function __construct() { require_once 'Zend/Date.php'; require_once 'DatabaseConnection.php'; } public function exportCSV($query) { $result = mysql_query($query); $fname = 'CSVFile.csv'; $headers = array(); $rowArray = array(); $numFields = mysql_num_fields($result); for ($i = 0; $i < $numFields; $i++) { $headers[] = mysql_field_name($result , $i); } $fp = fopen($fname, 'w'); if ($fp && $result) { header('Content-Type: application/csv'); header('Content-Disposition: inline; filename='.$fname); fputcsv($fp, $headers); while ($thisrow = mysql_fetch_row($result)) { fputcsv($fp, $thisrow); } readfile($fname); fclose($fp); } die; } } Thanks Hi, I have a PHP web page that displays the results from an SQL query. I was wondering if there was anything out there that would allow my users to click a link and then export the results of that query to a CSV file? Thanks Matt I have this code that is supposed to export the results of this query into a CSV. When I run the code in Firefox, it works perfectly. The only browser that it doesn't work in is IE. It opens an HTML page with the results on the page instead of prompting to download the CSV. Can anyone help me out? Code: [Select] <?php //code to export report to excel if(isset($_GET['date'])){ include('../inc/db.php'); if (!$link = mysql_connect($dbhost, $dbuser, $dbpass)) { echo 'Could not connect to mysql'; exit; } if (!mysql_select_db($dbname, $link)) { echo 'Could not select database'; exit; } $date = $_GET['date']; $select = "SELECT patients.lname, patients.fname, patients.dob, patients.sex, visit_data.cc, FROM_UNIXTIME(visit_data.reg_time), FROM_UNIXTIME(visit_data.discharged_time), visit_data.disposition, visit_data.leftby FROM patients, visit_data WHERE discharge_date = '$date' AND patients.patientid = visit_data.patientid"; $export = mysql_query ( $select ) or die ( "Sql error : " . mysql_error( ) ); $fields = mysql_num_fields ( $export ); for ( $i = 0; $i < $fields; $i++ ) { $header .= mysql_field_name( $export , $i ) . "\t"; } while( $row = mysql_fetch_row( $export ) ) { $line = ''; foreach( $row as $value ) { if ( ( !isset( $value ) ) || ( $value == "" ) ) { $value = "\t"; } else { $value = str_replace( '"' , '""' , $value ); $value = '"' . $value . '"' . "\t"; } $line .= $value; } $data .= trim( $line ) . "\n"; } $data = str_replace( "\r" , "" , $data ); if ( $data == "" ) { $data = "\n(0) Records Found!\n"; } header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=DailyLog.xls"); header("Pragma: no-cache"); header("Expires: 0"); print "$header\n$data"; } ?> Hello All, I am currently working on export to pdf, below is the code, i am able to see the data is getting retrieved from mysql table. I am having 2 issue: 1. When data is getting retrieved one column is on left corner it's now showing the data as it's Sno it gets hidden from left corner. 2. Second issue when i click on the link it's just adding a # tag on the url nothing else.
Please guide me to fix the code.
<!DOCTYPE html> <html> <head> <Title> Export Supplier / Visiters Details</Title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"/> <script type="text/javascript" src="tableExport.js"></script> <script type="text/javascript" src="jquery.base64.js"></script> <script type="text/javascript" src="html2canvas.js"></script> <script type="text/javascript" src="jspdf/libs/sprintf.js"></script> <script type="text/javascript" src="jspdf/jspdf.js"></script> <script type="text/javascript" src="jspdf/libs/base64.js"></script> <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> </head> <?php $con=mysqli_connect("localhost", "root", "", "cvmsdb"); $qry="SELECT * FROM tblsupvisitor"; $result=mysqli_query($con, $qry); $records = array(); while($row = mysqli_fetch_assoc($result)){ $records[] = $row; } ?> <div class="row" style="height:300px;overflow:scroll;"> <table id="tblsupvisitor" class="table table-striped"> <thead> <tr class="warning"> <th>SNO.</th> <th>Full Name</th> <th>Mobile Number</th> <th>Address</th> </tr> </thead> <tbody> <?php foreach($records as $rec):?> <tr> <td><?php echo $rec['ID']?></td> <td><?php echo $rec['FullName']?></td> <td><?php echo $rec['MobileNumber']?></td> <td><?php echo $rec['Address']?></td> </tr> <?php endforeach; ?> </tbody> </table> </div> <li><a href="#" onclick="$('#tblsupvisitor').tableExport({type:'json',escape:'false'});"> <img src="images/icon/logo.png" width="24px"> Export to Pdf</a></li> <li><a href="#" onclick="$('#tblsupvisitor').tableExport({type:'json',escape:'false'});"><img src="images/icon/logo.png" width="24px">JSON (ignoreColumn)</a></li> </html>
Kind Regards, Naveed. Hi: I think this would pertain to a PHP coding feature. I want to give a user the ability to click a link in the admin area called "Export Database" the will export the entire database like: myDataBase.sql and allow them to save it to their computer. They want to be able to make backups without logging into a PHP admin area. I use to do this with Access, but have not done this with mySQL. Has anyone done this before? ok, so I am not good with arrays, they confuse me. how can I set this up so that $data is all results that are returned from the database that correspond to it? Code: [Select] $data = array( array("firstname" => '$firstname', "lastname" => '$lastname', "age" => '$age')); the original code looked like: Code: [Select] <?PHP $data = array( array("firstname" => "Mary", "lastname" => "Johnson", "age" => 25), array("firstname" => "Amanda", "lastname" => "Miller", "age" => 18), array("firstname" => "James", "lastname" => "Brown", "age" => 31), array("firstname" => "Patricia", "lastname" => "Williams", "age" => 7), array("firstname" => "Michael", "lastname" => "Davis", "age" => 43), array("firstname" => "Sarah", "lastname" => "Miller", "age" => 24), array("firstname" => "Patrick", "lastname" => "Miller", "age" => 27) ); ?> but that won't do it for me. I need it so that the results from the database will automatically be filled in. basically, everyone that is in the database, so when a new member is added, they will show up too. please help Is it possible to export a single value from a mysql DB into a pre-existing excel spread sheet? I know how to create a spread sheet from php and mysql, but not a single value into a pre-existing excel document cell. here's basically what I'm doing: Creating a financial expense tracking report in php, user will input each expense, it will keep a running tally of the available funds in user's bank account. The user has an excel spread sheet that requires the current value of available funds and updates a budget forecast according. SO, I need to somehow get the available balance of the bank account (generated by user input) into the pre-existing excel spreadsheet. Any thoughts? I'm totally at a loss. Thanks! Hi I have a page displaying orders from a mysql table. How can i add a button which exports this to an excel file? I have a table in my php Mysql which contains some values.. Is it possible to get those values then export them to MS word with formatting? and make it like a table? Help pls. Hello, I had page that display results dynamically from the database, I need to export that html table to pdf. Any help? Thanks am using this code Code: [Select] <?php require_once 'PHPExcel.php'; require_once 'PHPExcel/IOFactory.php'; $objPHPExcel = new PHPExcel(); $objPHPExcel->getProperties()->setCreator("Matthew Casperson") ->setLastModifiedBy("Matthew Casperson") ->setTitle("Office 2007 XLSX Test Document") ->setSubject("Office 2007 XLSX Test Document") ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes."); $objPHPExcel->setActiveSheetIndex(0) ->setCellValue('A1', 'Hello') ->setCellValue('B2', 'world!') ->setCellValue('C1', 'Hello') ->setCellValue('D2', 'world!'); header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="test.xlsx"'); header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save('php://output'); ?> but excelsheet contain following error............. <b>Fatal error</b>: Class 'ZipArchive' not found in <b>C:\Program Files\xampp\htdocs\immigration\PHPExcelSourceCode\PHPExcel\Writer\Excel2007.php</b> on line <b>224</b><br /> but excelsheet contain this error............. please help how to fix it? Hello,
I have been assigned a PHP problem for my programming class. I'm a beginner so I am finding it really hard to figure out what to do. I got this far thanks to the internet. The problem is to take a list of students, place it in a multidimensional array, sort it, then divide it in half and place each half in two new files. I can't seem to figure out the last step. This is my code so far:
<?php
$students=array_map('str_getcsv', file('student.txt'));
foreach ($student as $key => $row) $lastname [$key] = strtolower ($row[2]);
array_multisort($lastname, SORT_ASC, $students);
$groupone= array_slice($students,0,10);
$grouptwo=array_slice($students,10);
echo "<pre>" , print_r($groupone), "</pre>";
echo "<pre>" , print_r($grouptwo), "</pre>";
$firstgroup=fopen(firstgroup.txt, "w");
echo fwrite ($firstgroup,$groupone);
fclose($firstgroup);
At this point I get an error because I should use a string not an array to write the new file.
I don't actually know how to create a new file and export the information onto it, this is me guessing.
I would really really appreaciaite it if someone could help me out or point me in the right direction.
Thank you so much,
Camilla
Hi i am new in PHP...have a project and have stuck...please please help.... I have a cart and i need to export the cart contents to excell...here is my code...please take a look and see if u can hepl... I also need to have an export button...and wen pressed the cart will be exported to excell thanks... <?php session_start(); if (!isset($_SESSION["customer"])) { header("location: customer_login.php"); exit(); } //error script error_reporting(E_ALL); ini_set('display_errors','1'); //connect to the database include "../storescripts/connect_to_mysql.php"; ?> <?php /////////////////////////////////////////////////////////////////////////////////// // SECTION ONE /////////////////////////////////////////////////////////////////////////////////// if(isset($_POST['pid'])){ $pid=$_POST['pid']; $wasFound=false; $i=0; //if the cart session is set or empty if(!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"])< 1){ //Runs if the cart is empty $_SESSION["cart_array"]= array(0 => array("item_id"=>$pid,"quantity"=>1)); }else{ //Runs if the cart has at least one item in it foreach($_SESSION["cart_array"] as $each_item){ $i++; while(list($key,$value)= each($each_item)){ if($key == "item_id"&&$value==$pid){ //the ite is in the cart..hence we adjust the quantity array_splice($_SESSION["cart_array"],$i-1,1,array(array("item_id"=>$pid,"quantity"=>$each_item['quantity']+1))); $wasFound=true; }//close if conditio }//close while loop }//close foreach loop if($wasFound==false){ array_push($_SESSION["cart_array"],array("item_id"=>$pid,"quantity"=>1)); } } header("location: cart.php"); } ?> <?php /////////////////////////////////////////////////////////////////////////////////// // SECTION TWO /////////////////////////////////////////////////////////////////////////////////// //if usser chooses to empty their sopping cart if(isset($_GET['cmd'])&& $_GET['cmd']=="emptycart"){ unset($_SESSION["cart_array"]); } ?> <?php /////////////////////////////////////////////////////////////////////////////////// // SECTION THREE /////////////////////////////////////////////////////////////////////////////////// //if usser chooses to empty their sopping cart if(isset($_POST['item_to_adjust'])&& $_POST['item_to_adjust']!=""){ //execute some code $item_to_adjust=$_POST['item_to_adjust']; $quantity=$_POST['quantity']; $quantity=preg_replace('#[^0-9]#i', '',$quantity); if($quantity >= 1000){$quantity=999;} if($quantity < 1){$quantity= 1;} $i=0; foreach($_SESSION["cart_array"] as $each_item){ $i++; while(list($key,$value)= each($each_item)){ if($key == "item_id"&&$value==$item_to_adjust){ //the ite is in the cart..hence we adjust the quantity array_splice($_SESSION["cart_array"],$i-1,1,array(array("item_id"=>$item_to_adjust,"quantity"=>$quantity))); }//close if conditio }//close while loop }//close foreach loop } ?> <?php /////////////////////////////////////////////////////////////////////////////////// // SECTION FOUR /////////////////////////////////////////////////////////////////////////////////// if(isset($_POST['index_to_remove'])&&$_POST['index_to_remove']!=""){ //access the array and run code to remove $key_to_remove= $_POST['index_to_remove']; if(count($_SESSION["cart_array"])<=1){ unset($_SESSION["cart_array"]); }else{ unset($_SESSION["cart_array"]["$key_to_remove"]); sort($_SESSION["cart_array"]); } } ?> <?php /////////////////////////////////////////////////////////////////////////////////// // SECTION FIVE /////////////////////////////////////////////////////////////////////////////////// $cartOutput=""; $cartTotal=""; if(!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"])< 1){ $cartOutput="<h2 align='center'>Your Cart Is Empty</h2>"; }else{ $i=0; foreach($_SESSION["cart_array"] as $each_item){ $item_id=$each_item['item_id']; $sql=mysql_query("SELECT * FROM products WHERE id='$item_id' LIMIT 1"); while($row=mysql_fetch_array($sql)){ $product_name=$row["product_name"]; $price=$row['price']; $details=$row['details']; } $pricetotal= $price*$each_item['quantity']; $cartTotal=$pricetotal + $cartTotal; //setlocale(LC_MONETARY,"en_KSHs"); //$pricetotal= money_format("%10.2n", $pricetotal); //dynamic table assembly $cartOutput .="<tr align='center'>"; $cartOutput .='<td><a href="../home.php?id=' . $item_id . '">' .$product_name . '</a><br/><img src="../inventory_images/' . $item_id . '.jpg" alt="' . $product_name . '" width="40" height="52" border="1"/></td>'; $cartOutput .='<td>' . $details . '</td>'; $cartOutput .='<td><form action="cart.php" method="post"> <input name="quantity" type="text" value="' . $each_item['quantity'] . '" size="1" maxlength="3" /> <input name="adjustBtn' . $item_id . '" type="image" value="change" src="../images/buttons/button_save.gif"/> <input name="item_to_adjust" type="hidden" value="' . $item_id . '" /> </form></td>'; //$cartOutput .='<td>' . $each_item['quantity'] . '</td>'; $cartOutput .='<td>' . $price . '</td>'; $cartOutput .='<td>' . $pricetotal . '</td>'; $cartOutput .='<td><form action="cart.php" method="post"> <input name="deleteBtn' . $item_id . '" type="image" value="X" src="../images/buttons/button_delete.gif"/> <input name="index_to_remove" type="hidden" value="' . $i . '" / ></form></td>'; $cartOutput .='</tr>'; $i++; } $cartTotal="<div align='right'>Your Total is KSHs. ".$cartTotal."</div>"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Your Cart</title> <link rel="stylesheet" href="../style/style.css" type="text/css" media="screen"/> </head> <body> <div align="center" id="mainWrapper"> <?php include_once("../templates/template_header3.php");?> <div id="pageContent"> <div style="margin:24px;text-align:left;"> <br/> <table width="100%" border="1" cellspacing="0" cellpadding="6"> <tr bgcolor="#00FF66" align="center"> <td width="17%" bgcolor="#5BD7D7"><strong>Product</strong></td> <td width="50%" bgcolor="#5BD7D7"><strong>Product Details</strong></td> <td width="7%" bgcolor="#5BD7D7"><strong>Quantity</strong></td> <td width="9%" bgcolor="#5BD7D7"><strong>Unit Price<br/>(KHSs.)</strong></td> <td width="10%" bgcolor="#5BD7D7"><strong>Total<br/>(KHSs.)</strong></td> <td width="7%" bgcolor="#5BD7D7"><strong>Remove</strong></td> </tr> <?php echo $cartOutput; ?> <!-- <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> --> </table> <?php echo $cartTotal; ?><br/> <br/> <a href="cart.php?cmd=emptycart">Empty Your Cart</a><br/> <a href="cart.php?cmd=export">Export</a><br/> </div> <?php include_once("../templates/template_footer.php");?> </div> </body> </html> I am new in programing. would like some help this is my cart.php file and i would like to export the cart contents into excel...after a user presses a submit button.. Please Please help...thanks This is my code so far:- Code: [Select] <?php session_start(); if (!isset($_SESSION["customer"])) { header("location: customer_login.php"); exit(); } //error script error_reporting(E_ALL); ini_set('display_errors','1'); //connect to the database include "../storescripts/connect_to_mysql.php"; ?> <?php /////////////////////////////////////////////////////////////////////////////////// // SECTION ONE /////////////////////////////////////////////////////////////////////////////////// if(isset($_POST['pid'])){ $pid=$_POST['pid']; $wasFound=false; $i=0; //if the cart session is set or empty if(!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"])< 1){ //Runs if the cart is empty $_SESSION["cart_array"]= array(0 => array("item_id"=>$pid,"quantity"=>1)); }else{ //Runs if the cart has at least one item in it foreach($_SESSION["cart_array"] as $each_item){ $i++; while(list($key,$value)= each($each_item)){ if($key == "item_id"&&$value==$pid){ //the ite is in the cart..hence we adjust the quantity array_splice($_SESSION["cart_array"],$i-1,1,array(array("item_id"=>$pid,"quantity"=>$each_item['quantity']+1))); $wasFound=true; }//close if conditio }//close while loop }//close foreach loop if($wasFound==false){ array_push($_SESSION["cart_array"],array("item_id"=>$pid,"quantity"=>1)); } } header("location: cart.php"); } ?> <?php /////////////////////////////////////////////////////////////////////////////////// // SECTION TWO /////////////////////////////////////////////////////////////////////////////////// //if usser chooses to empty their sopping cart if(isset($_GET['cmd'])&& $_GET['cmd']=="emptycart"){ unset($_SESSION["cart_array"]); } ?> <?php /////////////////////////////////////////////////////////////////////////////////// // SECTION THREE /////////////////////////////////////////////////////////////////////////////////// //if usser chooses to empty their sopping cart if(isset($_POST['item_to_adjust'])&& $_POST['item_to_adjust']!=""){ //execute some code $item_to_adjust=$_POST['item_to_adjust']; $quantity=$_POST['quantity']; $quantity=preg_replace('#[^0-9]#i', '',$quantity); if($quantity >= 1000){$quantity=999;} if($quantity < 1){$quantity= 1;} $i=0; foreach($_SESSION["cart_array"] as $each_item){ $i++; while(list($key,$value)= each($each_item)){ if($key == "item_id"&&$value==$item_to_adjust){ //the ite is in the cart..hence we adjust the quantity array_splice($_SESSION["cart_array"],$i-1,1,array(array("item_id"=>$item_to_adjust,"quantity"=>$quantity))); }//close if conditio }//close while loop }//close foreach loop } ?> <?php /////////////////////////////////////////////////////////////////////////////////// // SECTION FOUR /////////////////////////////////////////////////////////////////////////////////// if(isset($_POST['index_to_remove'])&&$_POST['index_to_remove']!=""){ //access the array and run code to remove $key_to_remove= $_POST['index_to_remove']; if(count($_SESSION["cart_array"])<=1){ unset($_SESSION["cart_array"]); }else{ unset($_SESSION["cart_array"]["$key_to_remove"]); sort($_SESSION["cart_array"]); } } ?> <?php /////////////////////////////////////////////////////////////////////////////////// // SECTION FIVE /////////////////////////////////////////////////////////////////////////////////// $cartOutput=""; $cartTotal=""; if(!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"])< 1){ $cartOutput="<h2 align='center'>Your Cart Is Empty</h2>"; }else{ $i=0; foreach($_SESSION["cart_array"] as $each_item){ $item_id=$each_item['item_id']; $sql=mysql_query("SELECT * FROM products WHERE id='$item_id' LIMIT 1"); while($row=mysql_fetch_array($sql)){ $product_name=$row["product_name"]; $price=$row['price']; $details=$row['details']; } $pricetotal= $price*$each_item['quantity']; $cartTotal=$pricetotal + $cartTotal; //setlocale(LC_MONETARY,"en_KSHs"); //$pricetotal= money_format("%10.2n", $pricetotal); //dynamic table assembly $cartOutput .="<tr align='center'>"; $cartOutput .='<td><a href="../home.php?id=' . $item_id . '">' .$product_name . '</a><br/><img src="../inventory_images/' . $item_id . '.jpg" alt="' . $product_name . '" width="40" height="52" border="1"/></td>'; $cartOutput .='<td>' . $details . '</td>'; $cartOutput .='<td><form action="cart.php" method="post"> <input name="quantity" type="text" value="' . $each_item['quantity'] . '" size="1" maxlength="3" /> <input name="adjustBtn' . $item_id . '" type="image" value="change" src="../images/buttons/button_save.gif"/> <input name="item_to_adjust" type="hidden" value="' . $item_id . '" /> </form></td>'; //$cartOutput .='<td>' . $each_item['quantity'] . '</td>'; $cartOutput .='<td>' . $price . '</td>'; $cartOutput .='<td>' . $pricetotal . '</td>'; $cartOutput .='<td><form action="cart.php" method="post"> <input name="deleteBtn' . $item_id . '" type="image" value="X" src="../images/buttons/button_delete.gif"/> <input name="index_to_remove" type="hidden" value="' . $i . '" / ></form></td>'; $cartOutput .='</tr>'; $i++; } $cartTotal="<div align='right'>Your Total is KSHs. ".$cartTotal."</div>"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Your Cart</title> <link rel="stylesheet" href="../style/style.css" type="text/css" media="screen"/> </head> <body> <div align="center" id="mainWrapper"> <?php include_once("../templates/template_header3.php");?> <div id="pageContent"> <div style="margin:24px;text-align:left;"> <br/> <table width="100%" border="1" cellspacing="0" cellpadding="6"> <tr bgcolor="#00FF66" align="center"> <td width="17%" bgcolor="#5BD7D7"><strong>Product</strong></td> <td width="50%" bgcolor="#5BD7D7"><strong>Product Details</strong></td> <td width="7%" bgcolor="#5BD7D7"><strong>Quantity</strong></td> <td width="9%" bgcolor="#5BD7D7"><strong>Unit Price<br/>(KHSs.)</strong></td> <td width="10%" bgcolor="#5BD7D7"><strong>Total<br/>(KHSs.)</strong></td> <td width="7%" bgcolor="#5BD7D7"><strong>Remove</strong></td> </tr> <?php echo $cartOutput; ?> <!-- <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> --> </table> <?php echo $cartTotal; ?><br/> <br/> <a href="cart.php?cmd=emptycart">Empty Your Cart</a><br/> </div> </div> <?php include_once("../templates/template_footer.php");?> </div> </body> </html> So i have this script, it pull data via mysql and inserts it into an excel file. However it does not properly tab each field as it should nor go to a new lines as it should instead it stick everything into 1 whole row. Ok but here's the kicker... this same identical script runs 100% fine on another website. The only difference is the query string. There it works fine on this new site it bugs out. any idea where the bug is? <?php include('dbcon.php'); $tablename = $_POST['tablename']; $full_query = "SELECT * FROM $tablename"; $header = ''; $data = ''; $export = mysql_query($full_query); $fields = mysql_num_fields($export); for ($i = 0; $i < $fields; $i++) { $header .= mysql_field_name($export, $i) . "\t"; } while($row = mysql_fetch_row($export)) { $line = ''; foreach($row as $value) { if ((!isset($value)) OR ($value == "")) { $value = "\t"; } else { $value = str_replace('"', '""', $value); $value = '"' . $value . '"' . "\t"; } $line .= $value; } $data .= trim($line)."\n"; } $data = str_replace("\r","",$data); if ($data == "") { $data = "\n(0) Records Found!\n"; } header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=monet_search_results.xls"); header("Pragma: no-cache"); header("Expires: 0"); print "$header\n$data"; ?> PS: This is a linux box if that makes a difference. THANKS! |