How to Make PDF Invoices From Database in PHP | PHP FPDF Tutorial

  Рет қаралды 130,630

GemaCode

GemaCode

Күн бұрын

welcome to php fpdf tutorial example videos.
in this example, i will use invoice from first chapter then combine it with database to make a dynamic invoices.
i have prepared some data beforehand using mock data generator.
there are a lot of websites which provides mock data generation for free. Just google "random data generator".
here is the database design i use in this example.
i have a master table for clients, with clientID as the key.
another table for invoice which contain clientID as a foreign key.
and finally, a table for items of each invoices, using invoiceID as the foreign key.
now let's begin.
first let's make a form page, to select which invoice to be generated.
here we need to get lists of invoices from database so lets make a database connection.
in my case, the database is named "invoiceDB".
make a form with "get" method, and "invoice-db dot php" as action, we will make the file later.
make a dropdown select input named invoiceID.
query the invoices id from database.
then show the result as options.
and don't forget to add submit button.
and the form is done.
now let's make the invoice.
to make things easier, just copy the php file from first chapter and rename it to invoice-db dot php.
add a database connection.
then query the invoice data from invoice table in database.
here we need to inner join clients table using clientID.
and use invoiceID received from GET method in where clause.
and don't forget to fetch the result in an array or object, so we can use it.
now lets replace the previous static invoice data with the dynamic data from database.
now lets display the items.
we need to query the item table in database and use invoiceID in where clause.
and make two variables to hold total tax and total amount.
display the items using where loop, replacing the contents.
we can add thousand separator for numbers using number_format function.
and at the end of each loop, accumulate the total tax and total amount.
finally, display the total amount, total tax, and total due.
this conclude this tutorial video.
thank you for watching, and see you in the next video.
Source Code : bit.ly/3hYdT0F
More tutorial on this series : goo.gl/TNqTN4 (PHP PDF Tutorial Series)

Пікірлер: 157
@ZubairPlays10
@ZubairPlays10 6 жыл бұрын
Hi, I have come across your channel and this is exactly what I have been looking for! You sir are great. Please may I have the source code for this? I will gladly appreciate it. I have also subbed to your channel. Thanks again.
@PS-xx3vz
@PS-xx3vz 5 жыл бұрын
Best solution i have ever met, I have come across your channel and this is exactly what I have been looking for! Please may I have the source code for this? I will gladly appreciate it.You are really great . please share source code. i will be very grateful. Thank you
@siddhugouda2444
@siddhugouda2444 6 жыл бұрын
Nice one there guys...keep up
@PizzaIsRocketScience
@PizzaIsRocketScience 6 жыл бұрын
Thank you for fast reply! Looking forward to play with it.
@amitgaud7863
@amitgaud7863 6 жыл бұрын
No need u have already posted me the source code and thanks for it 👍
@moment5196
@moment5196 6 жыл бұрын
Hello bro please can i have the source code ayoeniayeye@gmail.com
@ibrahimzeroual
@ibrahimzeroual 4 жыл бұрын
thank you so much
@billyandrewmaghirang6899
@billyandrewmaghirang6899 5 жыл бұрын
I get the undefined index invoiceID what should i do? seems like the get method doesnt work?
@djellebreda4456
@djellebreda4456 2 жыл бұрын
Very good
@vmark80
@vmark80 6 жыл бұрын
Hi mr Gemul, very nice and instructive tutorial. Is it possible to add/combine/import a pdf page (obviously non dynamically generated) into the resulting pdf invoices? thanx a lot
@SecrethLab
@SecrethLab 4 жыл бұрын
Hello. I have tried this method and i really like it. But for some reason when i pick a invoice in the drop down i get the same data no matter what number i pick. Any obvious reason why? EDIT: I figured it out. I forgot to use $_GET['InvoiceID'] from the html form. Ty for this guide it was really helpful
@pikahela
@pikahela Жыл бұрын
Thank you so much. I need this so much
@tobiussaolo5971
@tobiussaolo5971 5 жыл бұрын
I like this boss ....thanks alot
@ribzcosmos1986
@ribzcosmos1986 6 жыл бұрын
thanks mam ..for your instant reply....
@ribzcosmos1986
@ribzcosmos1986 6 жыл бұрын
sorry sir....
@hermanaben1146
@hermanaben1146 6 жыл бұрын
Very good tutorials! I watched the whole series and want to start now with the implementation on my male choir website. I want to include mysql data and use the header and footer features. Can you send me the source code? Thanks you in advance.
@hermanaben1146
@hermanaben1146 6 жыл бұрын
You can sent it to hjsaben@gmail.com. Thnks.
@parthaceo2090
@parthaceo2090 6 жыл бұрын
awesome 👍👍
@shrutijain9921
@shrutijain9921 5 жыл бұрын
While running the code I am getting the error invoice Id is undefined index and some data has already sent...Can you please help me with these errors.!
@shrutijain9921
@shrutijain9921 5 жыл бұрын
Thank you...😊
@ddimport
@ddimport 6 жыл бұрын
Hi mr Gemul, very good tutorial indeed. I am from Greece so my data contains greek letters than do not appear well in the resulting PDF. Any idea on how to fix this problem?
@ddimport
@ddimport 6 жыл бұрын
Thank you very much Gemul, you saved my day!!!
@ddimport
@ddimport 6 жыл бұрын
Hi again Mr Gemul. As the tutorial is perfectly working in my local server (localhost) y tried the same in my web hosting server, but it doesn't work there, I have changed all the information regarding the db connection but nothing. Any idea?
@ddimport
@ddimport 6 жыл бұрын
Hi Gemul, after testing, everything was just perfect except that my table in MySql database was starting with a capital letter (Orders and not orders) so calling the query "select * from orders" was working in my local server but in my web server was not. So now after correcting this error (select * from Orders) is working perfectly. Thank you very much.
@nozibusisomarumo2286
@nozibusisomarumo2286 6 жыл бұрын
Please help me. I keep on getting this error message "Notice: Undefined index: invoiceID in C:\xampp\htdocs\invoice\invoice.php on line 12 FPDF error: Some data has already been output, can't send PDF file. What should i do?
@nozibusisomarumo2286
@nozibusisomarumo2286 6 жыл бұрын
Hello. invoiceID does exist in my database. I am not sure what you mean by declaring invoiceID "index". Can you please explain by making an example for me, because declaring ($invoiceID) did not change the error. Apologies for the inconvenience, I am still a beginner.
@nozibusisomarumo2286
@nozibusisomarumo2286 6 жыл бұрын
nevermind. the form is displayed but now, its empty. the cell values are missing
@PabloEsparzaJimenez1
@PabloEsparzaJimenez1 6 жыл бұрын
Thanks!
@joymiegonzales5025
@joymiegonzales5025 Жыл бұрын
Or can you do coding electricity billing system using php.
@manickammurugappan9691
@manickammurugappan9691 6 жыл бұрын
How do i print more than one column from the database in a same cell?
@manickammurugappan9691
@manickammurugappan9691 6 жыл бұрын
Thank you very much :)
@itspriyankaaa
@itspriyankaaa 3 жыл бұрын
$pdf->Cell(130 ,20 , 'images/$result['image']',1,1); does not work, I don't know how to give the path
@GemaCode
@GemaCode 3 жыл бұрын
Double check your path. It should be relative to your script. Or better yet, use absolute path. You can use __DIR__ to get your current working directory.
@joymiegonzales5025
@joymiegonzales5025 Жыл бұрын
@@GemaCode hello po
@crysoliteangelyn6475
@crysoliteangelyn6475 5 жыл бұрын
Good work Please share the source code.
@nishantgholap5103
@nishantgholap5103 Жыл бұрын
can youn plese provide your db file .sql
@cjellal
@cjellal 5 жыл бұрын
How can I use a different size of paper? Is it possible?
@cjellal
@cjellal 5 жыл бұрын
@@GemaCode thank you! 😊
@sukanyagundanoor5660
@sukanyagundanoor5660 6 жыл бұрын
Hello, can you tell me how to add image from database or excel??
@sukanyagundanoor5660
@sukanyagundanoor5660 6 жыл бұрын
ok. Thank you for the reply. ya i know how to add static image. but i wanna dynamic image. can you tell me how to store image into database from excelsheet??
@osamaisam5853
@osamaisam5853 6 жыл бұрын
Hi . How to set font arabic utf8
@ravesalways
@ravesalways 6 жыл бұрын
I need help, like you do. Output : %PDF-1.3 3 0 obj endobj 4 0 obj Stream
@ravesalways
@ravesalways 6 жыл бұрын
header('Content-type: application/pdf'); Now, right? Should I change?
@ravesalways
@ravesalways 6 жыл бұрын
Yes,What should I do?
@ravesalways
@ravesalways 6 жыл бұрын
I make a like invoice-db.php file.
@ravesalways
@ravesalways 6 жыл бұрын
You have to contact the others? I'll show you the code modified.
@shipleym4530
@shipleym4530 Жыл бұрын
Can't see clearly this video
@petersababa4871
@petersababa4871 4 жыл бұрын
Help me with the source code please
@dontbeafraid5313
@dontbeafraid5313 5 жыл бұрын
Also can you do a tutorial to send data from pdf to mysql database?
@zack-aihtizaz
@zack-aihtizaz 4 жыл бұрын
Hai..salam. I got error as below (for invoice-db.php file):- 1) "Notice: Undefined index: invoiceID in...pdf\invoice-db.php on line 12" 2) "Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given...\pdf\invoice-db.php on line 13" line 12 is: invoiceID = '".$_GET['invoiceID']."'"); line 12 is: $invoice = mysqli_fetch_array($query); I cannot find what is the problem..
@itspriyankaaa
@itspriyankaaa 3 жыл бұрын
thanks a lot! One question, how to display image?
@nyashamakwavarara5438
@nyashamakwavarara5438 3 жыл бұрын
Lol. Did you figure it out because I also need help with that
@GemaCode
@GemaCode 3 жыл бұрын
Sorry for late reply, it's explained in my other video here kzbin.info/www/bejne/n52kgKKfjL6Sqrc hope it helps
@knzamy
@knzamy 5 жыл бұрын
very best tutorial in KZbin
@subhaRajamurugan
@subhaRajamurugan 4 жыл бұрын
please send coding for me
@qariibonline
@qariibonline Жыл бұрын
Thanks Alot
@ayandas9477
@ayandas9477 6 жыл бұрын
its a Great Tutorial mam..Please please do it in Codeigniter....... its my request
@ramsgarageband5784
@ramsgarageband5784 3 жыл бұрын
Great video ever
@jaiprakashnirala5152
@jaiprakashnirala5152 4 жыл бұрын
Thank u for helpful knowledge
@urvashiarya5148
@urvashiarya5148 6 жыл бұрын
THANKS FOR THIS VIDEO
@paulcamerino233
@paulcamerino233 5 жыл бұрын
Hello, I have a question on action="invoice-db.php" how can I make multiple choices of pdfs?
@paulcamerino233
@paulcamerino233 5 жыл бұрын
I'm sorry for the confusion I have solved this problem. Please nevermind that on the other hand I want to ask how can I compare values using _GET of the options selected? So if the user chooses an option it will get the option compare it and if correct display the desired outcome? And thanks for replying really appreciate it. Love your channel, btw.
@paulcamerino233
@paulcamerino233 5 жыл бұрын
@@GemaCode ohh so i have to set a variable first as a container of a value to be compared?? I will try these. Thank you very much!
@paulcamerino233
@paulcamerino233 5 жыл бұрын
@@GemaCode hey man i apologize but it didn't work also :(
@paulcamerino233
@paulcamerino233 5 жыл бұрын
@@GemaCode im really grateful for your response thanks again!
@paulcamerino233
@paulcamerino233 5 жыл бұрын
@@GemaCode no worries mate i solved the problem im really thankful to you and with all your videos i hope you keep on helping beginners like me. Thanks a lot!
@jzapapas
@jzapapas 4 жыл бұрын
Thank you Gemul. Can you point me to the source? Thank you, and I subscribed to your channel. JIm Zapapas
Generate a PDF with PHP
19:17
Dave Hollingworth
Рет қаралды 61 М.
Every parent is like this ❤️💚💚💜💙
00:10
Like Asiya
Рет қаралды 11 МЛН
POV: Your kids ask to play the claw machine
00:20
Hungry FAM
Рет қаралды 22 МЛН
Пришёл к другу на ночёвку 😂
01:00
Cadrol&Fatich
Рет қаралды 11 МЛН
7 Database Paradigms
9:53
Fireship
Рет қаралды 1,6 МЛН
Creating a simple pagination using php and mysql
15:57
Digital Fox
Рет қаралды 25 М.
How to Generate a PDF Invoice and Report in PHP: Complete Tutorial
7:18
Code With Yousaf
Рет қаралды 44 М.
How to make PDF Invoice in PHP using FPDF library
8:49
Code And Course
Рет қаралды 60 М.
How to Fetch Data From Database in PHP And Display HTML Tables
20:17
OnlineITtuts Tutorials
Рет қаралды 201 М.
OpenAI’s New ChatGPT: 7 Incredible Capabilities!
6:27
Two Minute Papers
Рет қаралды 191 М.
Every parent is like this ❤️💚💚💜💙
00:10
Like Asiya
Рет қаралды 11 МЛН