Learn to create a database in PhpMyAdmin and create PDF reports

in #utopian-io7 years ago (edited)

hi how are you all, at this time i will explain how to create database in phpmyadmin and also print database report with pdf, and this tutorial very useful for beginner.

What Will I Learn?

  • You will learn to create a database with phpmyadmin
  • You will learn to create database reports with PDF
  • You will make a connection to the database with php

Requirements

Tutorial Contents

  • First create a database using PhpMyAdmin,
    http://localhost/phpmyadmin
    database.JPG

  • then create a table in database with student name and column 4
    tabel.JPG

  • input variables: nim, name, birthday, phoneinto the database table in accordance with the following data:
    myadmin.JPG
    Database Description:
    Database name: tutorial
    Table name: student
    Number of rows: 4
    Variable name: nim, name, birthday, phone and in accordance with the type and value in accordance with the description in the picture above.

  • Next insert some data to display as a later report.
    insert.JPG
    After that select Go, it will get the following results
    go.JPG

If the database is already created, then we will display the report from the database with the PDf output.

  • Create a new file using a text editor and write the following code, function to save the configuration to the PhpMyAdmin database.

<?php
$host = "localhost";
$user = "root";
$password = "";
$database = "tutorial";
$connect = mysqli_connect($host, $user, $password, $database);
?>

Code Explanation
$host is used to deliver the web browser on the HTTP server installed on the local computer.
$ user to check the server user like xampp
$ passwordchecks the server user password
$ database to connect data services that have been made
$ connect to connect the connection with server and database
If you have set the configuration to the database, Then save with database.php name

  • Next create also a new file with the name index.php, then write the following code in your text editor.
< ?php
require('fpdf.php');
$pdf = new FPDF('l','mm','A5');
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(190,7,'UNIVERSITY UTOPIAN ',0,1,'C');
$pdf->SetFont('Arial','B',12);
$pdf->Cell(190,7,'LIS CLASs',0,1,'C');
$pdf->Cell(10,7,'',0,1);
$pdf->SetFont('Arial','B',10);
$pdf->Cell(20,6,'NIM',1,0);
$pdf->Cell(85,6,'NAMA MAHASISWA',1,0);
$pdf->Cell(27,6,'NO HP',1,0);
$pdf->Cell(25,6,'TANGGAL LHR',1,1);
$pdf->SetFont('Arial','',10);
include 'koneksi.php';
$mahasiswa = mysqli_query($connect, "select * from study");
while ($row = mysqli_fetch_array($mahasiswa)){
    $pdf->Cell(20,6,$row['nim'],1,0);
    $pdf->Cell(85,6,$row['name'],1,0);
    $pdf->Cell(27,6,$row['phone'],1,0);
    $pdf->Cell(25,6,$row['birthday'],1,1); 
}$pdf->Output(); 
?> 

Code Explanation
require ('fpdf.php'); function is to call FPDF library
$ pdf = new FPDF ('l', 'mm', 'A5'); as the intance object and provide the settings of the PDF page
$ pdf-> AddPage (); works to create a new page
$ pdf-> SetFont ('Arial', 'B', 16); sets the font type to be used
$ pdf-> Cell (190,7, UTOPIAN UNIVERSITY ', 0,1,' C '); works for printing strings
$ pdf-> Cell (10,7, '', 0,1); useful to give space down so as not too tight
include 'database.php'; to enter the database connection into the index.php page

  • The last step adds the FPDF script (fpdf.php)
    What is FPDF? FPDF is a PHP class which allows to generate PDF files with pure PHP, that is to say without using the PDFlib library. More information visit Official Site http://www.fpdf.org/
Version: 1.81
Date:2015-12-20
Author: Olivier PLATHEY
Download fpdf.php
  • Download fpdf.php listed above, then save the page one folder with database.php and index.php
  • then please access again http://localhost/YourFolderScript/, if the code you write is correct then the display will appear as follows:
    Results :
    ssf.JPG

Download Source Code & Database this tutorial in here
Curriculum
wait in the next tutorial :)



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Thanks you bro

Hey @harjuky I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Suggestions

  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

Get Noticed!

  • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 63562.42
ETH 2649.15
USDT 1.00
SBD 2.77