pere roca wrote: > hi everybody, > there is a nice tool using jquery/php to populate multiple select boxes out > there : http://remysharp.com/2007/09/18/auto-populate-multiple-select-boxes/ > > it must be a very stupid question but I’m trying to apply this tool to get > data from postgreSQL, but I always get an empty [] value. It means that the > array $json[] is not filled in the while statement. does it? have you actually checked var_dump($json) ? > But the dbase connection > and the query is correct ( I can check applying a echo “data: “.$row[0].”"; > and all the data is displayed). please note: '$row[0]' != '$row->label' > > I suppose pg_fetch_array is not used correctly (I have checked also > pg_fetch_object)...but I'm not sure because I'n newbie to jquery and json. > If someone has success connecting to postgresql... > > Thanks! > After inserting data.... > > $postgis_result=pg_query("select * from select_chain where > genus='".strtolower(pg_escape_string(strip_tags($_REQUEST['category'])))."'"); > > $json = array(); > > while (is_resource($postgis_result) && $row = I think it's safe to assume that $postgis_result will be a resource all the way through the while loop. > pg_fetch_array($postgis_result)) { so you fetch an array and then use the result as an object?? > $json[] = '"' . $row->label . '"'; > } > > echo '[' . implode(',', $json) . ']'; > die(); $json = array(); while ($row = pg_fetch_array($postgis_result, NULL, PGSQL_ASSOC)) $json[] = $row['label']; echo json_encode($json); // this function may not be available in your version of php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php