开发者

jQuery Selects Plugin, pull variables from database

I'm using this code to be able to generate an dynamic select: demo: http://www.erichynds.com/examples/jquery-related-selects code: https://github.com/ehynds/jquery-related-selects

I have changed the code of the orignal script from:

$counties = array();
$counties['1']['BARN'] = 'Barnstable';
$counties['1']['PLYM'] = 'Plymouth';
$counties['2']['CHIT'] = 'Chittenden';
$counties['3']['ANDE'] = 'Anderson';

To

$counties = array();
$sql = "SELECT
        id,
        naam,
        klant_id
        FROM contactpersoon
        ORDER BY klant_id ASC ";

if(!$res = mysql_query($sql,$con))
{
    trigger_error(mysql_error().'<br />In query: '.$sql);
}
else
{
    while ($row = mysql_fetch_array($res))
    {
        $counties[$row['klant_id'][$row['id'] =  htmlentities($row['naam']); 
    }
}

But for some reason the pulldown select list is not created when the changes are made. When I test the query, no 开发者_如何学JAVAerrors shown.


There is an error, at least in the code you posted. Your square brackets appear to be a bit off.

$counties[$row['klant_id'][$row['id'] =  htmlentities($row['naam']); 

should be

$counties [$row['klant_id']] [$row['id']] =  htmlentities($row['naam']); 

or

$a = $row['klant_id'];
$b = $row['id'];
$counties[a][b]= htmlentities($row['naam']);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜