jQuery选择插件,从数据库中提取变量
我使用此代码可以生成动态选择: 演示: 代码: 我已将原始脚本的代码更改为:jQuery选择插件,从数据库中提取变量,jquery,Jquery,我使用此代码可以生成动态选择: 演示: 代码: 我已将原始脚本的代码更改为: $counties = array(); $counties['1']['BARN'] = 'Barnstable'; $counties['1']['PLYM'] = 'Plymouth'; $counties['2']['CHIT'] = 'Chittenden'; $counties['3']['ANDE'] = 'Anderson'; 到 $countries=array(); $sql=“选择 身份证件 纳
$counties = array();
$counties['1']['BARN'] = 'Barnstable';
$counties['1']['PLYM'] = 'Plymouth';
$counties['2']['CHIT'] = 'Chittenden';
$counties['3']['ANDE'] = 'Anderson';
到
$countries=array();
$sql=“选择
身份证件
纳姆,
克兰特岛
来自contactpersoon
klant_id ASC命令”;
if(!$res=mysql\u查询($sql,$con))
{
trigger_error(查询中的mysql_error()。
,'.$sql);
}
其他的
{
while($row=mysql\u fetch\u数组($res))
{
$countries[$row['klant_id'][$row['id']=htmlentities($row['naam']);
}
}
但由于某些原因,在进行更改时不会创建下拉选择列表。
当我测试查询时,没有显示错误。至少在您发布的代码中有一个错误。您的方括号似乎有点错
$counties[$row['klant_id'][$row['id'] = htmlentities($row['naam']);
应该是
$counties [$row['klant_id']] [$row['id']] = htmlentities($row['naam']);
或
@不客气!帮你自己一个忙,买一份phpDesigner()或类似的文本编辑器,可以帮助你匹配开始括号、结束括号、方括号等。这会让你省去很多悲伤。
$counties [$row['klant_id']] [$row['id']] = htmlentities($row['naam']);
$a = $row['klant_id'];
$b = $row['id'];
$counties[a][b]= htmlentities($row['naam']);