我想$bank
在ShowDistrict
函数中使用来选择行
$sql = "SELECT DISTINCT `district` FROM `ctable` WHERE state='$_POST[id]' AND bank='$bank' ";
但它不起作用......有什么方法可以做到这一点?...提前致谢。
class SelectList
{
protected $conn;
public function __construct()
{
$this->DbConnect();
}
protected function DbConnect()
{
include "db_config.php";
$this->conn = mysql_connect($host,$user,$password) OR die("Unable to connect to the database");
mysql_select_db($db,$this->conn) OR die("can not select the database $db");
return TRUE;
}
public function ShowBank()
{
$sql = "SELECT DISTINCT `bank` FROM `ctable` WHERE 1 LIMIT 0, 30 ";
$res = mysql_query($sql,$this->conn);
$bank = '<option value="0">choose...</option>';
while($row = mysql_fetch_array($res))
{
$bank .= '<option value="' . $row['bank'] . '">' . $row['bank'] . '</option>';
}
return $bank;
}
public function ShowState()
{
$sql = "SELECT DISTINCT `state` FROM `ctable` WHERE bank='$_POST[id]'";
$res = mysql_query($sql,$this->conn);
$state = '<option value="0">choose...</option>';
while($row = mysql_fetch_array($res))
{
$state .= '<option value="' . $row['state'] . '">' . $row['state'] . '</option>';
}
return $state;
}
public function ShowDistrict()
{
$sql = "SELECT DISTINCT `district` FROM `ctable` WHERE state='$_POST[id]'";
$res = mysql_query($sql,$this->conn);
$district = '<option value="0">choose...</option>';
while($row = mysql_fetch_array($res))
{
$district .= '<option value="' . $row['district'] . '">' . $row['district'] . '</option>';
}
return $district;
}
public function ShowBranch()
{
$sql = "SELECT DISTINCT `bname` FROM `ctable` WHERE district='$_POST[id]'";
$res = mysql_query($sql,$this->conn);
$bname = '<option value="0">choose...</option>';
while($row = mysql_fetch_array($res))
{
$bname .= '<option value="' . $row['bname'] . '">' . $row['bname'] . '</option>';
}
return $bname;
}
}
$opt = new SelectList();