I have a static code to update some select boxes.
The original structure code:
$result = "
({
'options': [
{'value': '','description': '(pick an item)'},
{'value': 'test','description': 'test'},
{'value': 'test_2','description': 'test_2'}
]
});
";
I'm trying to make this dynamic and connect to my table in Postgresql Database but my code don't works.
Here is My Code:
if($value=="asus"){
require("includes/connection.php");
$sth = $dbh->prepare( "SELECT * FROM mapa_ferias WHERE area = 'Asus' " );
$sth->setFetchMode(PDO::FETCH_ASSOC);
$sth->execute();
$result = "
({
'options': [";
while($row = $sth->fetch()) {
$result += "{'value': '" + $row['nome'] + "','description': '" + $row['nome'] + "'},";
}
$result +=
"]
});
";
}
I hope you can help me. Thanks in advance.