This is a simplify version. I have an array $collected_data with the values
Array
(
[id] => 10711
[log_id] => 892
[form_id] => 2
[value] => fname
)
Array
(
[id] => 10712
[log_id] => 892
[form_id] => 3
[value] => lastname
)
Array
(
[id] => 10717
[log_id] => 892
[form_id] => 8
[value] => email
)
// ...
// etc
How can I have a output like:
fname lastname | email
fname lastname | email
etc
I tried:
foreach($form_data as $form_field)
{
$collected_data_sql = "SELECT * FROM `".WPSC_TABLE_SUBMITED_FORM_DATA."` WHERE `log_id` = '".$purchase['id']."' AND `form_id` = '".$form_field['id']."' LIMIT 1";
$collected_data = $wpdb->get_results($collected_data_sql,ARRAY_A);
$collected_data = $collected_data[0];
list($fname, $lastname, $email) = $collected_data;
echo $fname. ' '.$lastname.' | '.$email;
}
but that didn’t work.
Check the manual if you’re using a function you’re not totally clear about.
listexpects an array with 0-based numeric indexes. You can convert an array from string keys to numeric ones witharray_values:(in case that was your issue, I’m not so sure because your question does not give much information about your concrete problem)
Additionally you have an array of an array, so you need to extract the data you’re interested in as well, e.g.:
But that’s just exemplary.