ලේසියෙන්ම හොයාගන්න මෙතනින්

Showing posts with label SLIIT 3rd Year 1st Semester. Show all posts
Showing posts with label SLIIT 3rd Year 1st Semester. Show all posts

Generate Reports in PHP

You may need to generate reports based on your data retrieved from database. Here I will show how you can do it easily and free. I m using a library called FPDF.
FPDF is a PHP class which allows to generate PDF files with pure PHP, that is to say without using the PDFlib library. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs.

FPDF has other advantages: high level functions. Here is a list of its main features:

  • Choice of measure unit, page format and margins
  • Page header and footer management
  • Automatic page break
  • Automatic line break and text justification
  • Image support (JPEG, PNG and GIF)
  • Colors
  • Links
  • TrueType, Type1 and encoding support
  • Page compressing 

PHP, MySQL Integration - Perform Select, Insert, Update, Delete from PHP

In order to MVC Architecture, try to keep you coded php files seperately and try to reduce repeat save code. A simple basic programming concept. However to get establish database connection in PHP is very simple. Write a seperate php file for prepare database connection. In my case, my file name is db.php which I put it in controller folder.

<?php
    $host="localhost";
    $userName="root";
    $password="yourPassword";
    $db_name="databaseName";
    mysql_connect($host,$userName,$password) or die("Unable To Connect Database");
    mysql_select_db("$db_name") or die ("No Such Database.");

?>