Skip to main content

Create notification,store and retrive a particular user.

Notification Data table is:

as per user defined functionality , user want notification as per particular any user send.
if you want particular notification please follow following database structure :


Normally we can use following data table structure INNODB database use because mostly common used that, its very fast loading and primary and forgen key assign.
Free Teachnology provide free php tutorial as well as MySql,javascript,jquery knowlege :

INNODB,mysql,javascript,jquery


above image show that basic notification table structure pk_id is primary key of notification table , fk_uid is forgin key of user table of particular user primary key,

Following code is create notification table :

-- phpMyAdmin SQL Dump
-- version 4.5.2
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jun 07, 2018 at 12:16 PM
-- Server version: 10.1.13-MariaDB
-- PHP Version: 5.6.20

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";

--
-- Database: `makeathome`
--

-- --------------------------------------------------------

--
-- Table structure for table `notification`
--

CREATE TABLE `notification` (
  `pk_id` int(250) NOT NULL,
  `fk_uid` int(250) DEFAULT NULL,
  `status` enum('1','2','3') NOT NULL DEFAULT '1' COMMENT '1-pending,2-accept,3-decline',
  `title` text COMMENT 'message notification',
  `created_date` datetime NOT NULL COMMENT 'created date and time',
  `updated_date` datetime NOT NULL COMMENT 'updated date and time',
  `read_status` enum('1','2') NOT NULL DEFAULT '2' COMMENT '1-read message,2-unread message',
  `ip_address` varchar(250) DEFAULT NULL COMMENT 'ip address'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `notification`
--
ALTER TABLE `notification`
  ADD PRIMARY KEY (`pk_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `notification`
--
ALTER TABLE `notification`
  MODIFY `pk_id` int(250) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

above notification table required read,unread status because particular user notification you fetch at that time know that this particular user notification is read or not, when notification read then change status of notification table
ip address is filed store ip address of created notification its generally used for notify information,


Hope that you understand how to create notification and how to store into database


Comments

Popular posts from this blog

GUID for globally unique identifier

How to create GUID in php 1-guid stands for globally unique identifier generally used to create random unique strings in php, create access token in php 2-Mostly use of GUID for generating access token, generate unique id, generating unique string in php. Using this article how to create guide in php you can create a random string for any use to keep unique 3-GUID consists of alphanumeric characters only and is grouped in five groups separated by hyphens as seen in this example: 3F2504E0-4F89-11D3-9A0C-0305E82C3301 Eg:- <?php /** * Generate Globally Unique Identifier (GUID) * E.g. 2EF40F5A-ADE8-5AE3-2491-85CA5CBD6EA7 * * @param boolean $include_braces Set to true if the final guid needs * to be wrapped in curly braces * @return string */ function generateGuid($include_braces = false) { if (function_exists('com_create_guid')) { if ($include_braces === true) { return com_create_guid(); } else { return substr(com_cr...

All CSV data insert into MYSQL database

All CSV data insert into MYSQL database Function name : LOAD DATA LOCAL INFILE eg : # Make database connection :: $mysql = "LOAD DATA LOCAL INFILE 'Nulk-186677.csv' INTO TABLE product_details FIELDS TERMINATED BY ',' LINES TERMINATED BY '\\n' IGNORE 1 ROWS (@PRODUCT_TITLE,@PRODUCT_DESCRIPTION,@STYLE,@AVAILABLE_SIZES,@BRAND_LOGO_IMAGE,@THUMBNAIL_IMAGE,@COLOR_SWATCH_IMAGE,@PRODUCT_IMAGE,@SPEC_SHEET,@PRICE_TEXT,@PRODUCT_STATUS,@KEYWORDS) SET p_title = @PRODUCT_TITLE, p_desc = @PRODUCT_DESCRIPTION, p_style = @STYLE, p_available_size=@p_available_size, p_brand_logo_image=@p_brand_logo_imagem, p_brand_thumbnail_image=@p_brand_thumbnail_image, p_color_swatch_image=@p_color_swatch_image, p_image=@PRODUCT_IMAGE, p_spec_sheet=@SPEC_SHEET, p_prices_text=@PRICE_TEXT, p_status=@PRODUCT_STATUS, p_keywords=@KEYWORDS"; mysql_query($mysql);