Hi. I'm new to PHP and MySQL so pls take it easy on me. I'm trying to get away from the dark side (Windows) although php and mysql are available on that os. I'm using mysql 3.23.51 and php 4.2.1. I'm creating a job entry form with the fields:
Customer_Name - [drop down box with choices from the database]
Contact_Name - [choices from database but the choices should be limited to a particular customer]
Contact_Phone_Number - dependent on selected contact
Beginning Quantity - input
Quantity Shipped - input
Quantity Remaining - calculated
As stated above, I can't seem to find a way to limit the Contact Name choices when a particular customer is selected.
Here is a code segment for selecting the customer:
<?
$db = mysql_connect("localhost","root","");
mysql_select_db("APD_database",$db);
$result = mysql_query("SELECT * FROM Customers");
if ($result)
{
echo "<SELECT NAME='CustName'>";
while ($myrow = mysql_fetch_array($result))
{
echo "<OPTION VALUE=\"".$myrow["Customer_ID"]."\">".
$myrow["Customer_Name"]." </OPTION> ";
}
echo "</SELECT>";
}
mysql_close($db);
?>
This displays the customer names but its corresponding customer_id is written to the jobs table.
Here is for the contacts
<?
$db = mysql_connect("localhost","root","");
mysql_select_db("APD_database",$db);
$result = mysql_query("SELECT *FROM Contacts WHERE Customer_ID=$Cust;");
if ($result)
{
echo "<SELECT NAME='Contact'>";
while ($myrow = mysql_fetch_array($result))
{
echo "<OPTION VALUE=\"".$myrow["Contact_ID"]."\">".
$myrow["Contact_Name"]." </OPTION> ";
}
echo "</SELECT>";
}
mysql_close($db);
?>
Is it possible to automatically calculate for / limit the choices for Contacts without submitting? Any suggestions on the calculation of Quantity Remaining(read only)? I hope you guys can help. I'm sorry for the novice questions. thanks.