SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Jun 16, 2007, 07:19 #1
- Join Date
- Jun 2005
- Posts
- 313
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
populating form menus conditionally
Hi everyone,
I have a form which will allow me to populate a garments table within my database. Among the elements in the form, there is a suppliers drop down menu and a categories multiple select menu. I used the following code to populate these menus.
PHP Code:<?php
require_once('classes/database.php');
// this code always runs, and gets lists of suppliers and garment categories
$db=new Database('localhost','root','password','catalogue',0);
$getSuppliers = 'SELECT * FROM suppliers ORDER BY supplier';
$suppliers = $db->query($getSuppliers);
$getCategories = 'SELECT * FROM categories ORDER BY category';
$categories = $db->query($getCategories);
I guess you'd need to know a bit about the database structure for this: The garment types have their own table with its primary key also in the garments table as a foreign key. Since the supplier_id also exists in the garments table as a foreign key, I guess the connection between these two could be made.
The sizes and colours each have their own table and there's also garment_to_colour and garment_to_size lookup tables. These lookup tables contain the garment_id primary key from the garments table as well as the respective colour_id and size_id foreign keys from each of their tables.
I just wondered if someone could show me what the code might look like, in one of these scenarios?
Really appreciate any help offered.
-
Jun 16, 2007, 08:03 #2
- Join Date
- Jun 2006
- Location
- Tarpon Springs Fl.
- Posts
- 265
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You will have to use javascript/ajax or have the form be submited to get the variables and populate them on the next page based on the submited data. I hope that gives you someplace to look.
-
Jun 16, 2007, 09:41 #3
- Join Date
- Aug 2005
- Posts
- 453
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Does this code help:http://www.plus2net.com/php_tutorial..._down_list.php
Computers and Fire ...
In the hands of the inexperienced or uneducated,
the results can be disastrous.
While the professional can tame, master even conquer.
Bookmarks