I made a mysql table storing questions and their Drupal 6 attributes like prefix, suffix, options, title, value, type... etc.
Unfortunately the stored options value is an array and I get an error "warning: Invalid argument supplied for foreach()"
the code is:
$fruit = db_query("SELECT type,title, value, section, collapsible,collapsed, description, options, size, prefix, suffix, default_value FROM {table} ");
$count = 1;
while($slice = db_fetch_array($fruit)){
$section = $slice['section'];
$op = $slice['options'];
$form[$count] = array(
'#type' => $slice['type'],
'#title' => $slice['title'],
'#collapsible' => $slice['collapsible'],
'#collapsed' => $slice['collapsed'],
'#description' => $slice['description'],
'#options' => $op,
'#size' => $slice['size'],
'#prefix' => $slice['prefix'],
'#suffix' => $slice['suffix'],
);
$count = $count+1;
}
in one particular case the option is
array(t('yes'), t('no'))
where type is 'radios'
which is what is being stored as a varchar (blob isn't working either) (adding a comma doesn't help either.
$count
variable? Otherwise you'll end up with only one value. – Max