PHP somo la 72: Jinsi ya kuandaa PDF kutoana na data zilizopo kwenye database

PHP somo la 72: Jinsi ya kuandaa PDF kutoana na data zilizopo kwenye database

hapa utawenda utuma database wa ajl ya utengeneza maudhu ya PDF.

Download Post hii hapa

JINSI YA KUTUMIA DATABASE KUTENGENEZA PDF

Katika somo hili utajifunza jinsi ambavyo tutatengeneza PDF kutokana na data ambazo zipo kwenye PDF. 

 

Katika somo hili tutatumia data za faili la html ambalo tumelitumia katika somo lililopita. Hivyo basi tutatengeneza database yenye jina la pdf kisha tutaweka table yenye jina content, ambayo ina field 5 ambazo ni id, summary, content, autor, title. Baada ya hapo ndipo tutaweka data zetu.

 

Hatuwa ya kwanza:

Tengeneza database yenye jina pdf. Kisha tengeneza table iite content kisha weka filed hizo nilizotaja hapo juu. Unaweza kutuia code hizo hapo chini kutengeneza table hiyo.

CREATE TABLE `content` (

 `id` int(11) NOT NULL,

 `title` varchar(255) NOT NULL,

 `summary` varchar(255) NOT NULL,

 `content` text NOT NULL,

 `author` varchar(255) NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

 

ALTER TABLE `content`

 ADD PRIMARY KEY (`id`);

ALTER TABLE `content`

 MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

 

Hatuwa ya pili

Baada ya hapo tutaingiza data zetu za html ambazo tumezitumia katika somo lililopita. Unaweza kingiza tu kawaida ama ukatumia code nitakazokupa hapo jini.

INSERT INTO `content` (`id`, `title`, `summary`, `content`, `author`)

VALUES 

   (NULL, 'Mafunzo ya PDF',

       'Hapa utajifunza jinsi y akutengeneza PDF kwa kutumia data zilizopo kwenye database',

       '<!DOCTYPE html>

       <html lang="en">

       <head>

           <meta charset="UTF-8">

           <meta name="viewport" content="width=device-width, initial-scale=1.0">

           <title>Short Story</title>

           <style>

               body {

                   font-family: Arial, sans-serif;

                   line-height: 1.6;

                   margin: 0;

                   padding: 20px;

                   background-color: #f4f4f4;

               }

               h1 {

                   text-align: center;

                   color: #333;

               }

               p {

                   max-width: 800px;

                   margin: 0 auto 20px;

                   color: #555;

               }

           </style>

       </head>

       <body>

           <h1>The Enchanted Forest</h1>

           <p>Once upon a time, in a land far away, there was an enchanted forest where magical creatures lived in harmony. The forest was filled with towering trees, whose leaves shimmered with a golden hue. Every morning, the forest would come alive with the songs of birds and the chatter of woodland creatures.</p>

           <p>In the heart of this forest lived a young elf named Elara. Elara was known throughout the land for her kind heart and her ability to communicate with animals. She spent her days exploring the forest, helping any creature in need, and learning the secrets of the ancient woods.</p>

           <p>One day, while wandering through a particularly dense part of the forest, Elara stumbled upon a hidden glade. In the center of the glade was a crystal-clear pond, and next to the pond stood a majestic unicorn with a mane that sparkled like diamonds. The unicorn introduced himself as Orion, the guardian of the forest.</p>

           <p>Orion told Elara about a great danger that was approaching the forest. A dark sorcerer had discovered the forest\'s location and intended to drain its magic for his own evil purposes. The only way to save the forest was to find the ancient Tree of Life and awaken its power.</p>

           <p>Determined to save her home, Elara set off on a perilous journey. She faced many challenges along the way, including crossing a treacherous river, outsmarting a cunning fox, and navigating through a maze of thorns. But with the help of her animal friends, she overcame every obstacle.</p>

           <p>Finally, after days of travel, Elara found the Tree of Life. It was a magnificent tree with branches that reached the sky and roots that dug deep into the earth. Elara placed her hands on the trunk and spoke the ancient words of awakening. The tree began to glow with a brilliant light, and its magic spread throughout the forest, banishing the sorcerer\'s dark influence.</p>

           <p>The forest was saved, and its inhabitants rejoiced. Elara became a hero, and her bond with the forest grew even stronger. From that day on, the enchanted forest thrived, and its magic remained protected for generations to come.</p>

       </body>

       </html>',

       'Bongoclass'

   );

 

Hatuwa ya tatu

Baada ya hapo hatuwa hyo sasa ni kusoma hizo data kwenye faililetu la php. Tutatumia fail lil">...

Download Post hii hapa

Jiunge nasi WhatsApp
Upate Update zetu

Download App Yetu

Jifunze zaidi, na wasiliana nasi ukiwa na App yetu. Bofya link hapo chini kuweza kuipakua.

Download Now Bongoclass Zoezi la Maswali

Nyuma Endelea


Umeionaje Makala hii.. ?

Nzuri            Mbaya            Save
Author: Rajabu image Tarehe: 1970-01-01 03:33:44 Topic: PHP Main: ICT File: Download PDF Views 496

Share On:

Facebook WhatsApp
Sponsored links
👉1 Bongolite - Game zone - Play free game    👉2 kitabu cha Simulizi    👉3 Kitau cha Fiqh    👉4 Sira ya Mtume Muhammad (s.a.w)    👉5 Simulizi za Hadithi Audio    👉6 Madrasa kiganjani   

Post zinazofanana:

PHP somo la 54: PHP OOP class constant
PHP somo la 54: PHP OOP class constant

Katika somo hili utakwenda kujifunza jinsi ya kutumia constatnt kwenye class.

Soma Zaidi...
PHP - somo la 21: Jinsi ya kutafuta kitu kwenye database kwa mutumia PHP
PHP - somo la 21: Jinsi ya kutafuta kitu kwenye database kwa mutumia PHP

Katika somo hili utakwenda kujifundisha jinsi ya kutafuta taarifa maalumu kwenye database kwa kutumia PHP

Soma Zaidi...
PHP - somo la 36: Jinsi ya ku upload taarifa za mafaili kwenye database kw akutumia PHP
PHP - somo la 36: Jinsi ya ku upload taarifa za mafaili kwenye database kw akutumia PHP

katika somo hili utajfunza kukusanya taarifa za mafaili. kisha ku upload hayo mafaili. kisha kuandika hizo taarifa za mafaii kwenye database

Soma Zaidi...
PHP BLOG - somo la 5: Jinsi ya kuandika code za PHP kwa ajili ya kuweka post kwenye blog
PHP BLOG - somo la 5: Jinsi ya kuandika code za PHP kwa ajili ya kuweka post kwenye blog

Katika ukurasa huu utakwenda kujifunz jinsi ya kuandika code za php kwa ajili ya kutuma post yetu kwenye blog.

Soma Zaidi...
PHP BLOG - somo la 4: Jinsi ya kutengeneza ukurasa kwa ajili ya kupost
PHP BLOG - somo la 4: Jinsi ya kutengeneza ukurasa kwa ajili ya kupost

Katika somo hili utakwenda kujifunza jinsi ya kutengeneza ukurasa wa kupost kwa kutumia html form

Soma Zaidi...
PHP somo la 64: Jinsi ya kutengeneza database na kuingiza data kwa kuumia PDO
PHP somo la 64: Jinsi ya kutengeneza database na kuingiza data kwa kuumia PDO

Katika somo hili utakwenda kujifunza jinsi ya kutumia PDO kutengeneza database, kuteneneza table na kuingiza data moja na zaidi ya moja.

Soma Zaidi...
PHP - somo la 26: Jinsi ya kutengeneza system ya ku chat kw akutumia PHP
PHP - somo la 26: Jinsi ya kutengeneza system ya ku chat kw akutumia PHP

Katika somo hili utajifunza jinsi ya kutengeneza system ambayo mta atajisajili pamoja na kuchat na watumiaji wengine

Soma Zaidi...
PHP BLOG - somo la 3: Jinsi ya kutengeneza table kwenye databse kwa ajili ya blog
PHP BLOG - somo la 3: Jinsi ya kutengeneza table kwenye databse kwa ajili ya blog

Hapa utajifunza jinsi ya kutengeneza table ambayo tutaitumia kwenye blog yetu

Soma Zaidi...
PHP somo la 81: Cross - Orgn Resource Sharing - CORSE header
PHP somo la 81: Cross - Orgn Resource Sharing - CORSE header

Katika somo hili utakwenda kujifunza kuhusu Cross - Orgn Resource Sharing ama inafupishwa kama CORSE header

Soma Zaidi...
PHP - somo la 47: Jifunze kuhusu sql injection na kuizuia
PHP - somo la 47: Jifunze kuhusu sql injection na kuizuia

Katika somo hili utajwenda kujifunza jinsi ya kuzuia hacking kwenye website yako

Soma Zaidi...