I am trying to make a database driven website about a collecting hobby. The problem I am having is how do you design it properly.
Example:
Table A
companyID, companyName, companyBio
Table B
itemID, itemName, colorID, price
Table C
colorID, colorName
How do I design the input and output forms so that instead of having to know the companyID and colorID for an item they can select the companyName or see the colorName on the query results form?
Thanks
PHP beginner DB design questions
Moderator: General Moderators
Re: PHP beginner DB design questions
$query = mysql_query('select * from `companies`');
echo '<select name="company">';
while ($row = mysql_fetch_assoc($query)) {
echo '<option value="' . $row['companyId'] . '">' . $row['companyName'] . '</option>';
}
echo '</select>';
echo '<select name="company">';
while ($row = mysql_fetch_assoc($query)) {
echo '<option value="' . $row['companyId'] . '">' . $row['companyName'] . '</option>';
}
echo '</select>';
Re: PHP beginner DB design questions
You need to learn about basic kinds of form components, such as list boxes (SELECT elements, in HTML). And if you don't already have a firm grasp of relational database principles, you need to study that. There are lots and lots of tutorials available online. Try using a search engine, using key words like perhaps: html tutorial select and database relational tutorial.WestChi wrote:I am trying to make a database driven website about a collecting hobby. The problem I am having is how do you design it properly.
Example:
Table A
companyID, companyName, companyBio
Table B
itemID, itemName, colorID, price
Table C
colorID, colorName
How do I design the input and output forms so that instead of having to know the companyID and colorID for an item they can select the companyName or see the colorName on the query results form?
Thanks