Date: 02/26/08 (PHP Community) Keywords: database I'm trying to create an array that holds the name of the table as its key, and the field as its value. The array is populated via database output. However, the same table may be listed multiple times, since more than 1 field for each table can be present. $search_array = array(); $current_table = ''; $result = $d->dbQuery('SELECT the_table, the_fields FROM sitesearch ORDER BY id'); while($row = $d->dbFetchObject($result)): if ($current_array != $row->the_table): $search_array[$row->the_table] = $row->the_fields; $current_table = $row->the_table; else: $search_array[${$row->the_table}] .= ','.$row->the_fields; endif; endwhile;
|