Ok so this being my first post i hope im doing it correctly i took this from another post and tried to modify it to what i was supposed to do as u can see basic knowledge here.. ahhaah so i dont even know where to start what i need is 2 dynamic lists generated by a SQL table and after selecting both it should record on table_products on the storenumber column on produc XX the Number from the Store
<?php
$connection = mysql_pconnect("localhost:8889", "root", "root") or die("Error connecting. ".mysql_error());
mysql_select_db("crazy") or die("Error selecting db. ".mysql_error());
if(!isset($_POST['save']))
{
$query = "SELECT * FROM store";
$result = mysql_query($query) or die("Error in query. ".mysql_error());
echo "<form method = 'post' action = '".$_SERVER['PHP_SELF']."'>";
echo "<table width = '450' align = 'left'>";
echo "<tr>";
echo "<td align = 'right'>Store : </td>";
echo "<td>";
echo "<select name = 'Store'>";
echo "<option value = ''>Select Store</option>";
while($Store = mysql_fetch_object($result))
{
echo "<option value = '".$Store->Storenumber."'>".$Store->Storename."</option>";
}
echo "</select>";
echo "</td>";
echo "</tr>";
echo "</Form>";
echo "<form method = 'post' action = '".$_SERVER['PHP_SELF']."'>";
$Ark = "SELECT * FROM products";
$eds = mysql_query ($Ark) or die("Error in Query. ".mysql_error());
echo "<tr>";
echo "<td align = 'right'>Product : </td>";
echo "<td>";
echo "<select name = 'Product'>";
echo "<option value = ''>Select Product</option>";
while($Product = mysql_fetch_object($eds))
{
echo "<option value = '".$Product->Storenumber."'>".$Product->prodname."</option>";
}
echo "</select>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td></td>";
echo "<td>";
echo "<input type = 'submit' name = 'save' value = 'SAVE PRODUCT'>";
echo "<input type = 'reset' value = 'CLEAR FORM'>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</form>";
echo "$Store";
echo "$Product";
}
else
{
if(empty($_POST['Store']) || empty($_POST['Product']))
{
echo "$Store";
echo "Either you didn't select a Store or the Product field is empty!";
}
else
{
$Product = mysql_real_escape_string($_POST['Product']);
$query = "INSERT INTO products (Storenumber) VALUES('".$_POST['Store']."','$Product', NOW())";
if(mysql_query($query))
{
echo "Product successfully Related!";
}
else
{
echo "Unknown error has occurred.";
}
}
}
?>