473,385 Members | 1,309 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Need help with php class ezpdf

I'm trying to output mysql data to a pdf using ezpdf. I have successfully generated the first part of my report but the second part a lot of columns and of course won't across the page. The diagram below will probably explain what I'm trying to do.

Example of the current layout:

|---HEADER---|---HEADER2---|---HEADER3---|---HEADER4---|---HEADER5---|
| USERNAME1 | DATAFIELD1 | DATAFIELD2 | DATAFIELD3 | DATAFIELD3 |
| USERNAME2 | DATAFIELD1 | DATAFIELD2 | DATAFIELD3 |DATAFIELD3|
| USERNAME3 | DATAFIELD1 | DATAFIELD2 | DATAFIELD3 |DATAFIELD3|

Example of what I'm trying to accomplish:

|----HEADER1---|---HEADER2---|
| USERNAME1 | DATAFIELD1 |
|---HEADER3---|---HEADER4---|---HEADER5---|
| DATAFIELD2 | DATAFIELD3 | DATAFIELD4 |

|----HEADER1---|---HEADER2---|
| USERNAME2 | DATAFIELD1 |
|---HEADER3---|---HEADER4---|---HEADER5---|
| DATAFIELD2 | DATAFIELD3 | DATAFIELD4 |

|----HEADER1---|---HEADER2---|
| USERNAME3 | DATAFIELD1 |
|---HEADER3---|---HEADER4---|---HEADER5---|
| DATAFIELD2 | DATAFIELD3 | DATAFIELD4 |

If any one can help it would be very much appreciated.

Below is my test code

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. //http://sourceforge.net/projects/pdf-php/forums/forum/147987/topic/666093
  3. $con = mysql_connect("localhost","root","password");
  4. if (!$con)
  5.   {
  6.   die('Could not connect: ' . mysql_error());
  7.   }
  8.  
  9. mysql_select_db("dbname", $con);
  10. error_reporting(E_ALL);
  11.  
  12. include ('../pdf-php/class.ezpdf.php');
  13.  
  14. //$pdf =& new Cezpdf();
  15. $pdf =& new Cezpdf('LETTER','landscape');
  16. $pdf->selectFont('../pdf-php/fonts/Helvetica.afm');
  17.  
  18. //Margins (TOP,BOTTOM,LEFT,RIGHT)
  19. $pdf->ezSetCmMargins(2,1,1,1);
  20. $pdf->addText(105,595,8,"<b>TEXT</b>");
  21.  
  22. $data = array();
  23. // do the SQL query
  24. $query = "SELECT username, lastname, firstname, Overall, Lodging_Ease AS Lod_Ease, Lodging_Quality AS Lod_Qty, Web_Info, Registration AS Reg, Facilities AS Fac, Non_Academic AS Non_Aca, IT_Support AS IT, Instructors AS Instr, Course_Content AS Cont, Sequence AS Seq, Book_Handouts AS Books, PE FROM student_evaluation_results WHERE course = 'name'";
  25. $result = mysql_query($query);
  26. $total = mysql_num_rows($result);
  27. $pdf->addText(105,585,8,"<b>Evaluation ratings for course ". $test. "</b>");
  28. $pdf->addText(580,585,8,"<b>Processed on:  ". "</b>".date("m/d/Y"));
  29. // step through the result set, populating the array, note that this could also have been written:
  30. // while($data[] = mysql_fetch_assoc($result)) {}
  31. while($data[] = mysql_fetch_array($result, MYSQL_ASSOC)) {}
  32. // make the table
  33. $pdf->addText(580,595,8,"<b>Total records: ". $total. "</b>");
  34. $options = array('fontSize'=>8 );
  35. $title = 'YOUR TITLE HERE';
  36. $pdf->ezTable(&$data, $title, '', $options);
  37. // do the output, this is my standard testing output code, adding ?d=1
  38. // to the url puts the pdf code to the screen in raw form, good for checking
  39. // for parse errors before you actually try to generate the pdf file.
  40. if (isset($d) && $d){
  41. $pdfcode = $pdf->output(1);
  42. $pdfcode = str_replace("\n","\n<br>",htmlspecialchars($pdfcode));
  43. echo '<html><body>';
  44. echo trim($pdfcode);
  45. echo '</body></html>';
  46. } else {
  47. $pdf->stream();
  48. }
  49. ?>
Jun 10 '11 #1
2 3307
Markus
6,050 Expert 4TB
So, you want the headers displayed for every row in the pdf?
Jun 11 '11 #2
Yeah I think that would probably work. It would also help me understand how to arrange the data better.
Jun 14 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Martin Eisenberg | last post by:
Hi! I have a header with two classes, WidthLogger and Hyst. WidthLogger is declared first; its ctor takes a Hyst reference. Hyst declares WidthLogger a friend. Hyst constructs a WidthLogger...
1
by: Mario Rosario | last post by:
Hi, Thanks in advance for your help. I have a compile problem; actually a link problem, when I compile the class template below. I would appreciate if anyone can tell me what is wrong and how...
2
by: Kostadis.Spirou | last post by:
how can i make this programm with class???? #include <fstream> #include <cstdlib> #include <stdio.h> #include <stdlib.h> #include <iostream> using namespace std;
2
by: Migrant | last post by:
Hi Friends; I want develop a group logic with C# (n tier refraction).I know I must create a Class and inherit it But I don't have enough know-how about develop classes. Somebody can help me? ...
6
by: JSheble | last post by:
I come from a Delphi background, and am currently trying to port or convert some of our Delphi classes to C#. I've got a good handle on basic class design, but am a bit lost with some of the more...
1
by: Arvind P Rangan | last post by:
Hi, I have created a class library which i need to use in my ASPX file. when i say: Dim mylib As TestLib = new TestLib() it gives me an error saying type required. How do we use a class...
8
by: Brett Romero | last post by:
I have this situation: myEXE <needs< DerivedClass <which needs< BaseClass Meaning, myEXE is using a type defined in DerivedClass, which inherits from BaseClass. I include a reference to...
2
by: void.no.spam.com | last post by:
I'm a novice at Python, and found some code samples on how to use threads. My script is being run by a product that contains a Jython interpreter. Can someone please explain why I get the...
0
by: lukgol3 | last post by:
Hello. I have a problem with class ListView. I want to create control based on my class 'LisCtrl' This is how I create my class: #pragma once public ref class ListCtrl :public...
1
by: Marlissa Dijkman | last post by:
I want to use pop3 from PEAR. And now I need a class PEAR. Has somebody got it for me?
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.