Computer / Sytem Builder

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Hyarion
Forum Newbie
Posts: 12
Joined: Tue Nov 01, 2005 4:30 am
Location: South Africa

Computer / Sytem Builder

Post by Hyarion »

A friend has asked me to try and make a computer builder for his website. It would be something where one selects say they motherboard, then only RAM, Graphics Cards, etc. that are compatable with that motherboard are then available to choose, etc.

I see there's almost nothing easily findable on google. Could someone give me some tips on how to go about this?

I don't need a full script (although it would be useful for learning from), just some pointers on what sort of database structure, etc. I will need to try and work it into the current site's structure.
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

As you might have guessed from previous posts database structures aren't my strong point, so I'll leave that advice to someone else... but making the form would probably be easiest with javascript to populate drop down boxes on the selection of a previous ones, some examples of that can be found on google.

Also, google for something like online custom pc builder to get some ideas for form design.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Use a system similar to a shopping cart, or even a shopping cart in itself would be appropriate if your friend wishes to leave the components selection up to the user.
Hyarion
Forum Newbie
Posts: 12
Joined: Tue Nov 01, 2005 4:30 am
Location: South Africa

Post by Hyarion »

The form layout, drop down boxes, etc. I can work out/google. My main concern is how to structure it in the database (or variables for that matter).

Here's a very rough example:

If user chooses a motherboard that has an AGP slot then only AGP graphics cards are available to be chosen. If user chooses PCI-X motherboard then only PCI-X graphics cards are available.

This is just a simple example, in practice there would be ram considerations, harddrives, PSU, etc. So one can't have the user choosing a 250W PSU when he's got a dual 6800, 4 x 500Gb Harddrives, 2 DVD Writers and a Tape Backup Drive.

How could I link all the different parts to each other?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You'll need a parts table. This parts table would include a type field. Motherboards would likely get their own table. You'll have a many-to-many table between motherboards and parts compatible with them.
yum-jelly
Forum Commoner
Posts: 98
Joined: Sat Oct 29, 2005 9:16 pm

Post by yum-jelly »

If you going to be building computers then I would make the motherboard the key to your complete building process! The * items * table can contain all your products so you can build your select boxes using a * JOIN * on to your * cat * table that relates to your * items * table!

INSERT INTO `cat` VALUES (1, 'CPU', 'cpu');
INSERT INTO `cat` VALUES (2, 'Mother Board', 'smb');
INSERT INTO `cat` VALUES (3, 'System Memory', 'csm');
INSERT INTO `cat` VALUES (4, 'Sound Card', 'csc');
INSERT INTO `cat` VALUES (5, 'Monitor', 'cmm');
INSERT INTO `cat` VALUES (6, 'Network Card', 'cnc');
INSERT INTO `cat` VALUES (7, 'Hard Drive', 'chd');
INSERT INTO `cat` VALUES (8, 'CD/DV Rom', 'ccd');
INSERT INTO `cat` VALUES (9, 'Video Card', 'cvd');
INSERT INTO `cat` VALUES (10, 'Keyboard', 'ckb');
INSERT INTO `cat` VALUES (11, 'Mouse', 'cmt');
INSERT INTO `cat` VALUES (12, 'Computer Case', 'cct');
INSERT INTO `cat` VALUES (13, 'Operating System', 'cos');
INSERT INTO `cat` VALUES (14, 'Software Pack', 'csp');

cid = the category id
ccm = the category common name
cfn = the category http form element name



Once you have your * cat * table you can add items to your * items * table. The * items * table uses the * cat * "cid column", to insert and select items related to the * cat.ccm <- common name column *, using the * cat.cid column * as it's relationship key!


The items table contains every detail about the item, including....

mid, cid, cost, price, stock, info, oem

mid = the item id that is referenced in the * motherboard * table telling the motherboard that this item belongs to it (can be installed on it)
cid = the table relationship telling the * cat * table that this item is part of it category list!
cost = your cost for the item
price = the price the user will pay for the item
stock = how many are in stock
info = the complete information about the item
oem = the id that is used in the relationship with the * OEM * table of manufactures with name, phone, web site


The reason why I would put all the products together is because I don't want to many relationships, I just want as many as I need. Why?, because the building computer process should be the only complex database statements which will leave open easy database statements to do things that don't require complex joins....

Show products by single category... simple join by key
Show all products by each category... simple join by key (GROUP BY)
Show products by single OEM... simple join by key
....


yj
Hyarion
Forum Newbie
Posts: 12
Joined: Tue Nov 01, 2005 4:30 am
Location: South Africa

Post by Hyarion »

Thank you! This gives me lots of info to get started. :D
Post Reply