Posted inTechnology / JavaScript / jQuery / Mysql / php / Programming

jQuery Print Dynamic Content using PHP MySQL Example

Today, We want to share with you jQuery Print Dynamic Content using PHP MySQL Example.In this post we will show you PHP Web Print Generating Dynamic Content, hear for Partial Print Document Tutorial HTML div Content in PHP we will give you demo and example for implement.In this post, we will learn about How to create a dynamic webpage fetching data from a database in PHP with an example.

jQuery Print Dynamic Content using PHP MySQL Example

There are the Following The simple About jQuery Print Dynamic Content using PHP MySQL Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop Print Dynamic Content using JavaScript, jQuery, and PHP, so the Print DIV contents with CSS using JavaScript and jQuery for this example is following below.

Step 1 : Create Mysql Database Table

SQL creates a members table

CREATE TABLE `members` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
 `email` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
 `mobile` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
 `created_at` datetime NOT NULL,
 `updated_at` datetime NOT NULL,
 `status` enum('Active','Inactive') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Active',
 PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Step 2 :Database Configuration

database_config.php

connect_error) {
    die("Connection failed: " . $db->connect_error);
}

Step 3 : Print Dynamic Content

(index.php)HTML and PHP source code

query("SELECT id, name FROM members");
?>



    Select Member
    fetch_assoc()){ ?>
    <option value="">
    






Include the External jQuery library


Step 4 : JavaScript Source code

jQuery load() method


$(document).ready(function(){
    $('#getMember').on('click',function(){
        var memberID = $('#memberSelect').val();
        $('#memberInfo').load('retriveMember.php?id='+memberID,function(){
            var printContent = document.getElementById('memberInfo');
            var memberPrint = window.open('', '', 'width=900,height=650');
            memberPrint.document.write(printContent.innerHTML);
            memberPrint.document.close();
            memberPrint.focus();
            memberPrint.print();
            memberPrint.close();
        });
    });
});

Step 5 : Load SERVER SIDE Dynamic Data (retriveMember.php)

retriveMember.php

query("SELECT * FROM members WHERE id = ".$memberID);
    
    if($query->num_rows > 0){
        $memberData = $query->fetch_assoc();
    }
}
?>

Print Dynamic Content using JavaScript, jQuery, and PHP

Member Information

Member Name:

Member Email:

Mobile:

Created:

Status:

Member not found...

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about jQuery Print Dynamic Content using PHP MySQL Example.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype