Тёмный

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

GemaCode
Подписаться 5 тыс.
Просмотров 130 тыс.
50% 1

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)

Опубликовано:

 

8 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 157   
@knzamy
@knzamy 5 лет назад
very best tutorial in RU-vid
@ibrahimzeroual
@ibrahimzeroual 4 года назад
thank you so much
@djellebreda4456
@djellebreda4456 2 года назад
Very good
@jaiprakashnirala5152
@jaiprakashnirala5152 4 года назад
Thank u for helpful knowledge
@PizzaIsRocketScience
@PizzaIsRocketScience 6 лет назад
Thank you for fast reply! Looking forward to play with it.
@ramsgarageband5784
@ramsgarageband5784 3 года назад
Great video ever
@ribzcosmos1986
@ribzcosmos1986 6 лет назад
thanks mam ..for your instant reply....
@ribzcosmos1986
@ribzcosmos1986 6 лет назад
sorry sir....
@tobiussaolo5971
@tobiussaolo5971 5 лет назад
I like this boss ....thanks alot
@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
@pikahela
@pikahela Год назад
Thank you so much. I need this so much
@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
@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.
@siddhugouda2444
@siddhugouda2444 6 лет назад
Nice one there guys...keep up
@parthaceo2090
@parthaceo2090 6 лет назад
awesome 👍👍
@ayandas9477
@ayandas9477 6 лет назад
its a Great Tutorial mam..Please please do it in Codeigniter....... its my request
@qariibonline
@qariibonline Год назад
Thanks Alot
@urvashiarya5148
@urvashiarya5148 6 лет назад
THANKS FOR THIS VIDEO
@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.
@dontbeafraid5313
@dontbeafraid5313 5 лет назад
Also can you do a tutorial to send data from pdf to mysql database?
@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
@PabloEsparzaJimenez1
@PabloEsparzaJimenez1 6 лет назад
Thanks!
@billyandrewmaghirang6899
@billyandrewmaghirang6899 5 лет назад
I get the undefined index invoiceID what should i do? seems like the get method doesnt work?
@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 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-ilAOoiWY_tU.html hope it helps
@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..
@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!!!
@joymiegonzales5025
@joymiegonzales5025 Год назад
Or can you do coding electricity billing system using php.
@crysoliteangelyn6475
@crysoliteangelyn6475 4 года назад
Good work Please share the source code.
@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.
@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...😊
@nozibusisomarumo2286
@nozibusisomarumo2286 5 лет назад
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 5 лет назад
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 5 лет назад
nevermind. the form is displayed but now, its empty. the cell values are missing
@manickammurugappan9691
@manickammurugappan9691 5 лет назад
How do i print more than one column from the database in a same cell?
@manickammurugappan9691
@manickammurugappan9691 5 лет назад
Thank you very much :)
@osamaisam5853
@osamaisam5853 6 лет назад
Hi . How to set font arabic utf8
@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!
@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??
@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.
@jzapapas
@jzapapas 4 года назад
Thank you Gemul. Can you point me to the source? Thank you, and I subscribed to your channel. JIm Zapapas
@cjellal
@cjellal 5 лет назад
How can I use a different size of paper? Is it possible?
@cjellal
@cjellal 5 лет назад
@@GemaCode thank you! 😊
@nishantgholap5103
@nishantgholap5103 Год назад
can youn plese provide your db file .sql
@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
@shipleym4530
@shipleym4530 Год назад
Can't see clearly this video
@petersababa4871
@petersababa4871 4 года назад
Help me with the source code please
@subhaRajamurugan
@subhaRajamurugan 4 года назад
please send coding for me
Далее
Generate a PDF with PHP
19:17
Просмотров 60 тыс.
Bike vs Super Bike Fast Challenge
00:30
Просмотров 9 млн
Make PDF report in PHP with TCPDF | TCPDF Tutorial #1
15:39
Creating Dynamic PDF in PHP
22:23
Просмотров 32 тыс.
Creating a simple pagination using php and mysql
15:57
Save HTML Form Data to a MySQL Database using PHP
24:38
Creating Dynamic PDF file in PHP and HTML
33:33
Просмотров 43 тыс.