Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How would you do this??

Status
Not open for further replies.

nshenry03

Technical User
Feb 9, 2006
60
US
I have a table called ClassCodeTypes and a table called OIIItems. Tables are INNODB/MySQL

When users add a record to OIIItem, they must choose a ClassCodeType (CCTID is a foreign key in the OIIItem table). Depending on which CCT the user chooses, my company would like to show only certain fields on the addItem form (For example, a user chooses a fastener class code and the form displays weight, stocked min/max, etc, but if they choose a document class code, the form does not need a weight or stocked min/max so they are not displayed).

Right now I have an ENUM('Y', 'N') field in ClassCodeType for each field in OIIItems, so my PHP scripts can choose to display a field or not on the form.
---
Is there a way to automatically have all of the fields in OIIItems as a ENUM field in ClassCodeTypes (in case a field is added to OIIItems later on)

What is the best way to iterate through these columns using php?

This is what I'm doing for now
Code:
$query="SHOW COLUMNS FROM ClassCodeTypes WHERE Field LIKE 'required%' OR Field LIKE 'show%'";
				$result = safe_query($query);
				if (mysql_num_rows($result) > 0) {
					while ($row = mysql_fetch_array($result)) {	
						$FieldName = $row['Field'];
						if ($_GET["$FieldName"] == "") {
							$$FieldName = "N";
						} else {
							$$FieldName = "Y";
						}
					}
				}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top