Javascript 使用PHP显示基于先前选择的选择
我正在尝试显示所选客户的地址列表。以下是我目前掌握的信息:Javascript 使用PHP显示基于先前选择的选择,javascript,php,html,sql,odbc,Javascript,Php,Html,Sql,Odbc,我正在尝试显示所选客户的地址列表。以下是我目前掌握的信息: 客户: 当我删除地址表查询中的LIKE子句时,将显示所有客户的所有地址。有人知道我如何显示链接到所选客户的地址吗 提前感谢!将此select放入表单中,并在表单中添加一个submit按钮,稍作调整即可。如果您希望它不加载页面也不加载表单,请使用ajax。如果您希望显示所选客户的地址,请在select子句中添加where customer id=所选客户id I不确定您的意思,我添加了CustomerID=SELECTED Cus
客户:
当我删除地址表查询中的LIKE子句时,将显示所有客户的所有地址。有人知道我如何显示链接到所选客户的地址吗
提前感谢!将此select放入表单中,并在表单中添加一个submit按钮,稍作调整即可。如果您希望它不加载页面也不加载表单,请使用ajax。如果您希望显示所选客户的地址,请在select子句中添加where customer id=所选客户id I不确定您的意思,我添加了CustomerID=SELECTED CustomerID,但没有发生任何事情,你有一个示例查询吗?将此select放在表单中,并在其中添加一个提交按钮,进行一些小的调整,它就会工作。如果你希望它不加载页面,也不加载表单,请使用ajax。如果你想显示所选客户的地址,请在select中子句,add where customer id=selected customer id我不确定您的意思,我添加了CustomerID=selected CustomerID,但什么都没有发生,请问您有一个示例查询吗?
<?php
$customer_table = "SELECT * FROM dbo.tblSalesCustomers";
$customer_result = odbc_exec($conn, $customer_table);
?>
<div class="col-sm-6 col-lg-4">
<div class="form-group">
<label for="Address1" class="col-md-4 control-label">Customer:</label>
<div class="col-md-8">
<?php
echo ' <select class="form-control" id="cstmC" name="cstmC">';
while($row4 = odbc_fetch_array($customer_result))
{
echo" <option value='".$row4['CustomerID'] . "'>" . $row4['CustomerName'] ."</option>";
}
echo'</select>';
?>
</div>
</div>
</div>
<?php
$AddressIDC = $_POST['cstmC'];
$address_table = "SELECT * FROM dbo.tblSalesAddress WHERE CustomerID LIKE '".$AddressIDC."'";
$address_result = odbc_exec($conn, $address_table);
?>
<div class="col-sm-6 col-lg-4">
<div class="form-group">
<label for="Address1" class="col-md-4 control-label">Address:</label>
<div class="col-md-8">
<?php
echo ' <select class="form-control" id="adress" name="address">';
while($row6 = odbc_fetch_array($address_result))
{
echo" <option value='".$row6['AddressID'] . "'>" . $row6['AddressName'] ."</option>";
}
echo'</select>';
?>
</div>
</div>
</div>