Skip to content

Instantly share code, notes, and snippets.

View danielemarino's full-sized avatar

danielemarino

View GitHub Profile
<?php // Load items into a HTML select box via PHP & Ajax
$firstbox = $_POST['firstbox'];
$query = "SELECT * FROM mytable WHERE id_firstbox = '$firstbox';";
$result = pg_query($query) or die('Query failed: ' . pg_last_error());
$secondbox_arr = array();
if (pg_num_rows($result) > 0) {
while ($row = pg_fetch_array($result, NULL, PGSQL_ASSOC)) {
$secondbox_arr[] = array("id" => $row['id_secondbox'], "name" => $row['testo_secondbox']);
}