Barely Human
05-11-2005, 10:48 PM
Ok, im building a site. I have a submit product form which links to a table in my database and that works fine. I have 2 other tables, one called product_man and another called product_cat. I want a couple of drodown menus on the submit product form which will retrieve the data from the said tables. Im not sure how to do this. I also need the code to save the selected dropdown data somewhere on the database for retrival later on so i can show results for manufacturer, or catagory. I dont know the best way to do this though. i assume the the id number for the product on all 3 tables should be the same, but how do i do this?
Anyways, here is my submit form. I need 2 dropdowns at the top which bring up data from these tables and rows -
table= product_cat, row= category
table= product_man, row= manufacturer
Any help at all would be f$cking exelent..
<html>
<head>
<title>Add a Product</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.box {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
border: 1px solid #000000;
}
-->
</style>
</head>
<body>
<?php
if(isset($_POST['save']))
{
$product = $_POST['product'];
$description = $_POST['discription'];
$price = $_POST['price'];
$techsheet = $_POST['techsheet'];
if(!get_magic_quotes_gpc())
{
$product = addslashes($product);
$description = addslashes($description);
$price = addslashes($price);
$techsheet = addslashes($techsheet);
}
include 'library/config.php';
include 'library/opendb.php';
$query = "INSERT INTO product_details (product, description, price, techsheet) VALUES ('$product', '$description', '$price', '$techsheet')";
mysql_query($query) or die('Error ,query failed');
include 'library/closedb.php';
echo "Product '$product' added";
}
?>
<form method="post">
<table width="700" border="0" cellpadding="2" cellspacing="1" class="box" align="center">
<tr>
<td width="100">Category</td>
<td><select name="category" cols="50" rows="10" class="" id="category"></select></td>
</tr>
<tr>
<td width="100">Manufacturer</td>
<td><select name="manufacturer" cols="50" rows="10" class="" id="manufacturer"></select></td>
</tr>
<tr>
<td width="100">Product</td>
<td><textarea name="product" cols="50" rows="10" class="box" id="product"></textarea></td>
</tr>
<tr>
<td width="100">Description</td>
<td><textarea name="description" cols="50" rows="10" class="box" id="description"></textarea></td>
</tr>
<tr>
<td width="100">Price</td>
<td><textarea name="price" cols="50" rows="10" class="box" id="price"></textarea></td>
</tr>
<tr>
<td width="100">Techsheet URL</td>
<td><textarea name="techsheet" cols="50" rows="10" class="box" id="techsheet"></textarea></td>
</tr>
<tr>
<td width="100">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2" align="center"><input name="save" type="submit" class="box" id="save" value="Save Article"></td>
</tr>
</table>
</form>
</body>
</html>
Anyways, here is my submit form. I need 2 dropdowns at the top which bring up data from these tables and rows -
table= product_cat, row= category
table= product_man, row= manufacturer
Any help at all would be f$cking exelent..
<html>
<head>
<title>Add a Product</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.box {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
border: 1px solid #000000;
}
-->
</style>
</head>
<body>
<?php
if(isset($_POST['save']))
{
$product = $_POST['product'];
$description = $_POST['discription'];
$price = $_POST['price'];
$techsheet = $_POST['techsheet'];
if(!get_magic_quotes_gpc())
{
$product = addslashes($product);
$description = addslashes($description);
$price = addslashes($price);
$techsheet = addslashes($techsheet);
}
include 'library/config.php';
include 'library/opendb.php';
$query = "INSERT INTO product_details (product, description, price, techsheet) VALUES ('$product', '$description', '$price', '$techsheet')";
mysql_query($query) or die('Error ,query failed');
include 'library/closedb.php';
echo "Product '$product' added";
}
?>
<form method="post">
<table width="700" border="0" cellpadding="2" cellspacing="1" class="box" align="center">
<tr>
<td width="100">Category</td>
<td><select name="category" cols="50" rows="10" class="" id="category"></select></td>
</tr>
<tr>
<td width="100">Manufacturer</td>
<td><select name="manufacturer" cols="50" rows="10" class="" id="manufacturer"></select></td>
</tr>
<tr>
<td width="100">Product</td>
<td><textarea name="product" cols="50" rows="10" class="box" id="product"></textarea></td>
</tr>
<tr>
<td width="100">Description</td>
<td><textarea name="description" cols="50" rows="10" class="box" id="description"></textarea></td>
</tr>
<tr>
<td width="100">Price</td>
<td><textarea name="price" cols="50" rows="10" class="box" id="price"></textarea></td>
</tr>
<tr>
<td width="100">Techsheet URL</td>
<td><textarea name="techsheet" cols="50" rows="10" class="box" id="techsheet"></textarea></td>
</tr>
<tr>
<td width="100">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2" align="center"><input name="save" type="submit" class="box" id="save" value="Save Article"></td>
</tr>
</table>
</form>
</body>
</html>