Click here to Skip to main content
15,896,425 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I am trying to create a search function for my online shopping system . I have the following tables:

SQL
CREATE TABLE `product` (
    `product_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
    `user_id` int(11) unsigned NOT NULL,
    `brand_id` int(11) unsigned NOT NULL,
    `model_id` int(11) unsigned NOT NULL,
    `category_id` int(11) unsigned NOT NULL,
    `name` varchar(255) NOT NULL DEFAULT '',
    `description` text NOT NULL,
    `serial` varchar(255) NOT NULL DEFAULT '',
    `total_images` tinyint(3) unsigned NOT NULL DEFAULT '0',
    `total_views` int(11) unsigned NOT NULL DEFAULT '0',
    `cover` int(11) unsigned NOT NULL DEFAULT '0',
    `status` tinyint(1) unsigned NOT NULL DEFAULT '0',
    PRIMARY KEY (`product_id`)
);

CREATE TABLE product_categories (
    category_id int(11) unsigned NOT NULL AUTO_INCREMENT,
    parent_id int(11) unsigned NOT NULL DEFAULT '0',
    name varchar(100) NOT NULL,
    description text NOT NULL,
    slug varchar(100) NOT NULL,
    ext varchar(4) NOT NULL DEFAULT '',
    total_products int(11) unsigned NOT NULL DEFAULT '0',
    status tinyint(1) unsigned NOT NULL DEFAULT '0',
    PRIMARY KEY (`category_id`),
    UNIQUE KEY `slug` (`slug`)
);

CREATE TABLE product_brands` (
   brand_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
    name varchar(100) NOT NULL,
    slug varchar(100) NOT NULL DEFAULT '',
    ext varchar(4) NOT NULL DEFAULT '',
    total_products int(11) unsigned NOT NULL,
    updated tinyint(1) NOT NULL DEFAULT '0',
    PRIMARY KEY (`brand_id`)
);

CREATE TABLE product (
    model_id int(11) unsigned NOT NULL AUTO_INCREMENT,
    category_id int(11) unsigned NOT NULL DEFAULT '0',
    brand_id int(11) unsigned NOT NULL DEFAULT '0',
    name varchar(100) NOT NULL,
    slug varchar(100) NOT NULL DEFAULT '',
    total_products` int(11) unsigned NOT NULL,
    PRIMARY KEY (`model_id`)
);


What i'm trying to achieve is a autocomplete features that works something
like: category brand product. A few examples:
apple -> apple iphone, apple ipad, apple ipod..
iphone -> iphone 5s, iphone 5, iphone 6..
apple iphone -> apple iphone 5s, apple iphone 6s...


please suggest me how to implement these type of functionality ?
Posted
Updated 30-Jan-15 0:41am
v2
Comments
Nathan Minier 30-Jan-15 7:02am    
This is far more contingent on your frontend language than your SQL queries.

You'll need to implement an AJAX autocomplete (called typeahead if you're using bootstrap). You'll need a backend service that returns just the data (I like JSON, personally). It's insanely simple with .NET MVC; if you're using web forms you might have some work ahead, though.
ZurdoDev 30-Jan-15 7:47am    
First, decide on an autocomplete control.
manvendra patel 4-Feb-15 8:04am    
is there any code for these type in asp.net with database ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900