How to change the background, text or a div color on real time with php, mysql, ajax and jQuery ?

Description:- Hello! In this lesson I’ll show you guys the logic with little example to how to change the background, text or a div color on real time with php, mysql, ajax and jQuery.
Maybe you guys have better logics to shorten my code. If you have then please comment below.

So for this lesson make the following files step by step:-
1. create database and name it “color”
2. create row in database(color) and name it colorname
3. Create 2 columns 
    (i) id
    (ii) colorcode
4. Download jQuery file
5. Create changebg.php
6. Create config.php
7. Create insertcolor.php

1. config.php

pdf of config file

2. changebg.php

pdf of changebg file

3. insertcolor.php

pdf of insertcolor file

*NOTE :- I’m providing you pdf files as my wordpress text editor is not working well copy and paste code and make the php files with the same name of files and then goto your browser after making database and then run the changebg.php file.
Live demo is available here