How to connect database with Pglife project

PG Life Project Solution
 It is simple to connect Pglife php file with mysql database . If you are facing error to solve , we are here to help you. Please Read to end .

How to connect database with Pglife project

  1. On Xampp Server
  2. On Mysql
  3. Click On Mysql Admin 
  4. Open Admin panel . 
 DataBase:- On Database here our all data like login id ,password ,name etc are stored here.It is simple to use you can write here any query or create any table here.

Error Are You Face?

Fatal error: Uncaught mysqli_sql_exception: Unknown database 'pglife' in D:\xampp\htdocs\PGLife\includes\database_connect.php:2 Stack trace: #0 D:\xampp\htdocs\PGLife\includes\database_connect.php(2):
mysqli_connect('127.0.0.1', 'root', ", 'pglife') #1 D:\xampp\htdocs\PGLife\property_list.php(3): require('D:\\xampp\\htdocs...') #2 {main} thrown in D:\xampp\htdocs\PGLife\includes\database_connect.php on line 2

Fatal error: Uncaught mysqli_sql_exception: Unknown database 'pglife' in D:\xampp\htdocs\PGLife\includes\database_connect.php:2 Stack trace: #0 D:\xampp\htdocs\PGLife\includes\database_connect.php(2): mysqli_connect('127.0.0.1', 'root', ", 'pglife') #1 D:\xampp\htdocs\PGLife\property_list.php(3): require('D:\\xampp\\htdocs...') #2 {main} thrown in D:\xampp\htdocs\PGLife\includes\database_connect.php on line 2


Solution of this written below:-


Copy Below SQL Query And Paste It 

First Select PGlife Database Then create Table How Create Table Just Copy Query And Past it to you Database query . 


Create Table For Users

CREATE TABLE users (
    id INT NOT NULL AUTO_INCREMENT,
    email VARCHAR(100) NOT NULL,
    password VARCHAR(100) NOT NULL,
    full_name VARCHAR(100) NOT NULL,
    phone VARCHAR(20) NOT NULL,
    gender ENUM('male','female') NOT NULL,
    college_name VARCHAR(100) NOT NULL,
    PRIMARY KEY(id)
    );


Create Table For Properties

CREATE TABLE properties (
    id INT NOT NULL AUTO_INCREMENT,
    city_id INT NOT NULL,
    name VARCHAR(100) NOT NULL,
    address VARCHAR(255) NOT NULL,
    description LONGTEXT NOT NULL,
    gender ENUM('male','female', 'ubisex') NOT NULL,
    rent INT NOT NULL,
    rating_clean FLOAT(2,1) NOT NULL,
    rating_food FLOAT(2,1) NOT NULL,
    rating_safety FLOAT(2,1) NOT NULL,
    PRIMARY KEY(id),
    FOREIGN KEY(city_id) REFERENCES cities(id)
    );

Create Table For Amenities

CREATE TABLE amenities(
    id INT NOT NULL AUTO_INCREMENT,
    name VARCHAR(100) NOT NULL,
    type VARCHAR(100) NOT NULL,
    icon VARCHAR(30) NOT NULL,
    PRIMARY KEY(id)
    );

Create Table For Properties Amenities

CREATE TABLE properties_amenities(
    id INT NOT NULL AUTO_INCREMENT,
    property_id INT NOT NULL,
    amenity_id INT NOT NULL,
    PRIMARY KEY(id),
    FOREIGN KEY(property_id) REFERENCES properties(id),
    FOREIGN KEY(amenity_id) REFERENCES amenities(id)
    );

Create Table For Testimonials

CREATE TABLE testimonials (
    id INT NOT NULL AUTO_INCREMENT,
    property_id INT NOT NULL,
    user_name VARCHAR(100) NOT NULL,
    content LONGTEXT NOT NULL,
    PRIMARY KEY(id),
    FOREIGN KEY(property_id) REFERENCES properties(id)
    );

Create Table For Interseted user properties

CREATE TABLE interested_users_properties (
     id INT NOT NULL AUTO_INCREMENT,
    user_id INT NOT NULL,
    property_id INT NOT NULL,
    PRIMARY KEY(id),
    FOREIGN KEY(user_id) REFERENCES users(id),
    FOREIGN KEY(property_id) REFERENCES properties(id)
    );

Download This Table Query 

You have to wait 30 seconds.

Generating Download Link...



NOW Write Query For Enter Data In Table  

INSERT INTO 
  `cities` 
    (`id`, `name`) 
  VALUES
    (1, 'Delhi'),
    (2, 'Mumbai'),
    (3, 'Bengaluru'),
    (4, 'Hyderabad');


INSERT INTO 
  `users` 
    (`id`, `email`, `password`, `full_name`, `phone`, `gender`, `college_name`) 
  VALUES
    (1, 'anuj.kalbalia@gmail.com', 'b1b3773a05c0ed0176787a4f1574ff0075f7521e', 'Anuj Kalbalia', '9535100112', 'male', 'NITD'),
    (2, 'shadab@gmail.com', 'b1b3773a05c0ed0176787a4f1574ff0075f7521e', 'Shadab Alam', '9876543210', 'male', 'NITJ'),
    (3, 'aditya@gmail.com', 'b1b3773a05c0ed0176787a4f1574ff0075f7521e', 'Aditya Sood', '9876543210', 'male', 'Chandigarh University'),
    (4, 'radhika@gmail.com', 'b1b3773a05c0ed0176787a4f1574ff0075f7521e', 'Radhika Bhatia', '9876543210', 'female', 'Delhi University');


Full Insert Data Download Here👇


 
You have to wait 58 seconds.

Generating Download Link...

Post a Comment

Please do not enter any spam link in the comment box.

Previous Post Next Post