行を選択する関数で使用$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();