How to save table data to save to PDF using php?

Hello

I have a load of data loading into a table of data in mysql table. Since I create a "save data" button to save the data in the table in pdf format. can someone help me how to save it and show me a few steps. Here is my code for the table:

<?php
  $servername = "localhost";
  $username = "root";
  $password = "pass";
  $dbname = "ses";
   
   
  // Create connection
  $conn = new mysqli($servername, $username, $password, $dbname);
  // Check connection
  if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
  }
   
  $sql = "SELECT No, Calon, ID, Jurusan, Undi FROM candidates order by Undi desc";
  $result = $conn->query($sql);
  ?>
  <?php
  if ($result->num_rows > 0) {
  echo "<table >

  <tr>
  <th>No</th>
  <th>Candidate</th>
  <th>ID Number</th>
  <th>Programme</th>
  <th>Vote</th>
  </tr>";
  // output data of each row
  while($row = $result->fetch_assoc()) {
  echo "<tr>
  <td align='center'>" . $row["No"]. "</td>
  <td>" . $row["Calon"]. "</td>
  <td>" . $row["ID"]. "</td>
  <td>" . $row["Jurusan"]. " </td>
  <td>" . $row["Undi"]. "</td>

  </tr>";
  }

  echo "</table>";
  } else {
  echo "0 results";
  }
  $conn->close();
  ?>

and here is the HTML for the button:

can someone help me?

Thank you

Look at the script on the FPDF under 'Scripts' site below

2002-12-25 Olivier Table with MySQL

First you must download the file of fpdf.php since the site under the downloads"" section.

Copy the first block of coding 'Source' from the example script and save it under-mysql_table.php

Next copy the second code block and insert it into a new document in DW, modify the code as shown in red below and save it as pdf_output.php - make sure that the paths to include the mysql_table.php and the (fpdf.php file which is included in the mysql_table.php file) are correct.

Also change the connection to your database in the code below.

require('mysql_table.php');

class PDF extends PDF_MySQL_Table
{
function Header()
{
  //Title
  $this->SetFont('Arial','',18);
  $this->Cell(0,6,'Database Data',0,1,'C');
  $this->Ln(10);
  //Ensure table header is output
  parent::Header();
}
}

//Connect to database
mysql_connect('server','login','password');
mysql_select_db('db');

$pdf=new PDF();
$pdf->AddPage();
//First table: put all columns automatically
$pdf->Table('SELECT No, Calon, ID, Jurusan, Undi FROM candidates order by Undi desc');

$pdf->Output();
?>

If you have set up properly and navigate to - pdf_output.php - it should produce a pdf of the extracted data in your database.

A draw back is it uses mysql and mysqli - which is not an immediate problem, as long as you do not mix mysql and mysqli - as this is a stand alone page, it should be ok. (and of course as long as your server still supports the mysql extension)

Tags: Dreamweaver

Similar Questions

  • How to 'Save as PDF' using Safari 5.1.7 in Windows 7?

    I use Safari 5.1.7 but can't "Save as PDF".  Y at - it a tip for that?

    THX

    You must have a software for creating PDF as Adobe Acrobat Pro or Nitro PDF for features.

  • How to save a PDF file in Adobe so it appears correctly in the Firefox default drive?

    I have seen discussions on how to change your own settings of Firefox for poster correctly PDF files (documents to look at a PDF in Firefox 19 +) However, I'm looking for a solution on how to save a PDF file so that they display correctly in the new default Firefox reader. Our files PDF is bad looking and I can not go in the browser of each clients and difficulty settings (http://www.cherrybekaertbenefits.com/wp-content/uploads/2014/07/ACA_Infographic_072114.pdf). Meet them all parameters within the Acrobat Distiller is going to fix this without the Viewer to enter their own arrangements?

    Hmm, not a subtle difference.

    We did not have many experts PDF or Adobe Illustrator users post advice here; those who might be sprinkled around on other forums, blogs or support sites.

    I noticed when you view the properties of the PDF in Adobe Reader that the PDF has been created with optimization for active fast Web view. This is a feature that allows the progressive rendering of PDF files over a slow connection (http://helpx.adobe.com/illustrator/kb/optimize-native-pdf-file-sizes.html#...). You can try to re - generate the PDF file with this feature turned off to see if that makes a difference?

  • How to save a pdf file published on Adobe Reader touch?

    How to save a pdf file published on Adobe Reader Touch?

    Hi Rdurward,

    On the closure of the PDF document, changes is stored on mobile devices. There is no explicit button to save the changes.

    Kind regards
    Nicos

  • How can save a PDF with password

    How can save a PDF with password

    Hi MacUser2,

    Trial is for 30 days.

    Once the trial is over you will be able to open PDF files by using the password that you have installed.

    Kind regards
    Nicos

  • How to save a PDF on iBook

    How to save a PDF on iBook

    Hi Peter,.

    What iOS version do you use?

    Open any pdf file in a browser, and on the upper right corner under the address bar, you will see an option to open the file in the iBooks app.

    Kind regards

    Rahul Tyagi

  • I am new to adobe.  Saved gall .pdf for Adobe PANEUSE Xi and can be seen on the screen.  How to save the .pdf on my Flash drive file: L?

    I am new to Adobe.  Have the .pdf file in Adobe Reader Xi and can open and see on my screen.  How to save the .pdf on my Flash Drive file: L?

    I would advise against ever record directly onto a flash drive. For no reason I can understand this often broken leaves files behind.

    Instead, just save it to your desktop and drag it to the usual flash drive (in Windows Explorer or the Finder).

  • How to save a pdf file so that the tool pane is not displayed

    How to save a pdf file so that the tool pane does not appear when the file is opened?

    Ah!  Thank you.  You are a star.

  • How to save a pdf page 2 (created in Illustrator) to be used in a web site?

    How to save a pdf page 2 (created in Illustrator) to be used in a web site?

    When I save my Illustrator file in pdf format, it is about 2600 k, my website admin will allow only storage of 5000 kb. I tried to 'save for web', but that only saves the first page of my document. Any suggestions other than payment for more storage?

    What predefined pdf do you use? Try to file more small size rather than default illustrator.

    Save for web doesn't PDF, so not a multipage control.

  • How to save a variable, using AJAX, a database mySQL using Coldfusion?

    I have a jquery script that takes a background color of an image using AJAX. I would like to save the variable, var rgba = e.rgba () on a MySQL database. The person who created the script says to use: $.post("color.php",{rgba:reba});) to save a database with AJAX. How to save the var rgba using coldfusion to do CF?

    The script:

    < script >

    ;(Function($){

    $. fn.canvasify = function (f) {/ / faster than dynamically converting one pixel at a time}

    return this.map (function () {}

    If {(this.nodeName=="IMG)"}

    var canvas = $("< canvas >')

    This.SRC = this.src / / IE fix

    $(this) .one ('load', function () {}

    Canvas.Attr ({width: this.width,:this.height}) height})

    Canvas [0]. GetContext ('2d'). DrawImage(This,0,0,this.) Width, this. Height)

    $(this) .replaceWith (canvas)

    })

    return the canvas [0]

    } else {}

    return this

    }

    })

    }

    function Rgba (rgba) {}

    This.RGBA = rgba

    this.toString = function() {return "rgba (" + Array.prototype.join.call (this.rgba, ',') + ")"}

    }

    $. {Event.prototype.RGBA = Function ()}

    var x = this.offsetX | (this.pageX - $(this.target) .offset () .left),.

    this.offsetY = y | (this.pageY - $(this.target) .offset () .top).

    nodeName = this.target.nodeName

    If (nodeName = "CANVAS")

    return new Rgba (this.target.getContext('2d').getImageData(x,y,1,1) .data)

    ElseIf (nodeName = 'IMG') {}

    var canvas = document.createElement ("canvas")

    Canvas.Width = 1

    Canvas.Height = 1

    canvas.getContext('2d').drawImage (this.target, x, y, 1, 1, 0, 0, 1, 1)

    return new Rgba (canvas.getContext('2d').getImageData (0,0,1,1) .data)

    } otherwise return null

    }

    (}) (jQuery)

    {$(function()}

    $("figure").append ("< class p =" rgba">" ")

    $('img').canvasify ravishing (demo))

    $('img').click (demo)

    function {persons

    var rgba = e.rgba (),

    digit = $(this) .parent)

    Figure.CSS ('background-color', RGBA). Find ("p"). Text (RGBA)

    }

    });

    < /script >

    < style >

    {p.RGBA}

    background: white;

    color: black;

    border: 1px solid red;

    min-height: 20px;

    }

    < / style >

    Here's some pseudocode

    AJAX

    ...

    $data = {RGBA: $rgba, var1 = $var1, var2 = $var2, etc.};

    ...

    var ajaxResponse = $.ajax({)

    type: 'POST',

    URL: '.. '. /.. /dir/settings.CFC? Method = saveBGColor,

    contentType: "application/json; charset = utf-8 ",

    data: JSON.stringify ($data).

    etc.

    });

    Settings.CFC

  • How to save a PDF file with zoom as TIFF/PNG of quality equal?

    I have a graphic photographic resolution in PDF (vector graphics). Zoom in Acrobat results in an impeccable oversampled image you expect from vector graphics. However, I can not save the PDF upscale as an oversampled TIFF or PNG - I get horrible artifacts. How can I get Acrobat to save the PDF with zoom a PNG/TIFF image?

    Thank you very much...

    You can get what you want with instant tool under editing, AA XI. This will give you a screenshot of what is shown on the screen. The best way is to open the vector graphic in Illustrator and work directly with vector illustration.

  • How to save a PDF file as v1.4 in Acrobat Pro?

    Hello

    I am currently using the Adobe Acrobat X Pro. I sent me the documents that I have to change to v1.4.

    So far, I've been sent v1.3, v 1.7 v1.5, v1.6.

    I need TO change the versions of the PDF files provided to v1.4 because I then send the documents to someone else who uses software that only accepts files PDF v1.4.

    Please tell me how to do this in Adobe Acrobat X Pro. If this CAN be done in the X Pro, should what software I do this?

    One of the people sending me files has asked how to do this in Adobe Acrobat 9 Pro also. Are the directions the same in the two versions?

    Thanks for your help!

    PDF 1.4 is what you will get if you use optimization PDF (file > save as > PDF optimized) to make it compatible with "Acrobat 5.0 and later.

    In Acrobat 9, select: Advanced > optimization PDF

  • How to save a PDF file in order to open them up to the 100% instead of 177% zoom?

    Currently all of the PDF files I record 177% still open. It is not very legible and requires users to zoom in to 100% in order to see the entire document. I would like to save my PDF files so they automatically open to 100% (AKA Fit to Page) whenever a customer opens to them. Is this possible? I tried several methods, but even check adjust to Page in the menu print and then to print a PostScript does not. Any help is greatly appreciated!

    Open the file in Acrobat Pro, set the initial view, and then save the file.

  • How to save a PDF file as an XML using Adobe Acrobat Pro XI?

    Each save because is has encountered an error "PDF files that contain XFA forms can be saved in the specified format.".  This error prevents save the PDF to another type of file.  Please send your suggestions.  Thank you

    The message is pretty clear, right? You cannot export forms XFA (those created in LiveCycle Designer) to other formats.

  • DV7 - 7333cl: how to extract usable data from a bad drive using 22 pins adapter usb to SATA on the new HD

    Greetings HP Forum,

    Recently, I replaced a bad hard drive on my laptop. I need now step by step procedure to extract usable data from the wrong drive using 22 pins adapter usb to SATA on the new HD.

    NOTE: I can't not all data that especially if some of the software downloaded on the replaced disk can be altered. Should I first download Internet Antivirus to protect my new hard drive? I'm not an expert, or even close to this when you work on the back of the laptop, so I'll have to step by step how to download and to partition the data recoverable and software, etc..

    Thanks in advance for your help... I greatly appreciate it!

    See you soon!

    Wes

    It is not complex. Attach the drive to the adapter and connect it to any other computer with good antivirus and antispyware installed. I use Malwarebytes and Avast. When you connect the adapter with the drive connected to the usb port, the drive will appear and it will be assigned a letter maybe E:\ or F:\ or something else. Immediately, he analyzes with the antivirus and anti-spyware. Quarantine or delete any virus or malware it finds. Then, it's just a matter of navigate the disk and copy and paste the contents of the host computer in a directory for this purpose. Obviously, you can copy from documents word, photos, music files, but you cannot copy the applications like Microsoft Word, iTunes. Photoshop.  You may need to take ownership of the files on the old hard drive, but Windows will guide you through this. Don't know what else I can answer.

Maybe you are looking for

  • [javascript application] this feature has been disabled

    I saw articles that seem to solve this problem, but I have a problem. When I go to tools > Options > content I not give me the option to activate Javascript. I'm unable to delete bookmarks and have no idea what else can be done. Any help will be appr

  • Y510p BIOS will not update

    I just tried to install the new BIOS for my y510p that came out July 2, but when I tried to run, I got "BIOS version compare error! I have no idea why this is happening. Any help would be appreciated, I know how much we all love a new BIOS . Thank yo

  • Very disappointed with Yoga 10 HD +.

    First of all, I talked to the customer service agent is not even aware of such a model. He said 'Are you talking about a 10 Ideapad', ' what is HD + "etc. > Sharpness much less than expected > Animations terribly slow/choppy (as slide it between the

  • Kodak digital camera c190 digital

    I can not gat my digital camera to transfer pctures to my laptop. I deleted the software and then reinstalled and still, she does not transfer them. Any one with answers please I need your help

  • the iPod device is displayed as camera

    Original title: Windows 7 think my ipod nano 5th GEN is a camera When I try to plug my ipod nano, in Windows 7, an icon of the camera gets up & it trys to import photos, then he says the file is not found.  I have the last update on the nano & the la