mhunt
06-23-2005, 04:19 AM
Hi, i have a database filled with things and the way i want the client to be able to edit it is by first selecting the product from one drop down menu, then from whatever they choose in that drop down menu, the second is populated with the information that goes with it. Heres what i have:
<?php
if($session->isAdmin()){
?>
<form action="" method="post" name="gun" class="forms" enctype="multipart/form-data">
Select a Manufacturer:<br />
<select name="manufacturer">
<option value=""></option>
<?php
$query = "SELECT * FROM `gun_manufacturers`";
$result = mysql_query($query, $conn);
$numrows = mysql_num_rows($result);
for ($i=0; $i < $numrows; $i++)
{
$row = mysql_fetch_array($result, MYSQL_ASSOC);
echo "<option value=\"{$row['gunManufacturerID']}\">{$row['gunManufacturerName']}</option>";
}
?>
</select><br />
<select name="gun">
<?php
$gunManufacturerID = ( get_magic_quotes_gpc() ) ? $_POST['manufacturer'] : addslashes( $_POST['manufacturer'] );
$query = "SELECT * FROM `guns` WHERE `gunManufacturerID = {$gunManufacturerID}";
$result = mysql_query($query, $conn);
$numrows = mysql_num_rows($result);
for ($i=0; $i < $numrows; $i++)
{
$row = mysql_fetch_array($result, MYSQL_ASSOC);
echo "<option value=\"{$row['gunID']}\">{$row['gunName']}</option>";
}
?>
</select>
</form>
<?
} else {
echo "Sorry you do not have access to this page.";
}
?>
I know there is probably an easier way to do those queries too with joins, but im not too experienced with them and I can't figure out what the join would look like. Any help is greatly appreaciated
<?php
if($session->isAdmin()){
?>
<form action="" method="post" name="gun" class="forms" enctype="multipart/form-data">
Select a Manufacturer:<br />
<select name="manufacturer">
<option value=""></option>
<?php
$query = "SELECT * FROM `gun_manufacturers`";
$result = mysql_query($query, $conn);
$numrows = mysql_num_rows($result);
for ($i=0; $i < $numrows; $i++)
{
$row = mysql_fetch_array($result, MYSQL_ASSOC);
echo "<option value=\"{$row['gunManufacturerID']}\">{$row['gunManufacturerName']}</option>";
}
?>
</select><br />
<select name="gun">
<?php
$gunManufacturerID = ( get_magic_quotes_gpc() ) ? $_POST['manufacturer'] : addslashes( $_POST['manufacturer'] );
$query = "SELECT * FROM `guns` WHERE `gunManufacturerID = {$gunManufacturerID}";
$result = mysql_query($query, $conn);
$numrows = mysql_num_rows($result);
for ($i=0; $i < $numrows; $i++)
{
$row = mysql_fetch_array($result, MYSQL_ASSOC);
echo "<option value=\"{$row['gunID']}\">{$row['gunName']}</option>";
}
?>
</select>
</form>
<?
} else {
echo "Sorry you do not have access to this page.";
}
?>
I know there is probably an easier way to do those queries too with joins, but im not too experienced with them and I can't figure out what the join would look like. Any help is greatly appreaciated