Hi all,
I’m new to the forum and hoping someone maybe able to help. I am making a parts database for my office. I have 2 tables I’m using on the page. One is “Parts” which has a field called “part_cat” which has the category id number its a member of and a table called “Categories” which has 2 fields “cat_id” & “cat_name”. Im trying to may a page to update the parts records and I am stuck on the select drop down box. If anyone has any ideas or can give me some help I would be grateful. The page has already loaded * from the parts table.
[php]
$sql = "SELECT * FROM categories ORDER BY cat_name";
$result = mysql_query($sql);
if(!$result)
{
echo 'Error';
}
else
echo '<td><select name="part_cat">';
while ($row = mysql_fetch_assoc($result))
{
echo '<option value="' . $row['cat_id'] . '"';
if ($part_cat=' . $row[cat_id] . ')
{
echo 'selected>' . $row['cat_name'] . '</option>\n';
}
else
{
echo '>' . $row['cat_name'] . '</option>\n';
}
}
echo '</select></td>';
[/php]
Thank you.