Here is the data I have:
ID | Name | Family
1 | John | Doe
2 | Jane | Doe
3 | John | Man
4 | Jane | Blah
Basically what I am trying to do is group them by Family. I am getting the data inside a while statement and I just tried using array and array_push but that doesn’t work at all.
Any ideas or suggestions on how to do this?
I am going to ouput this data for jquery for creating optgroups which would be grouped by Family. Currently here is what is happening:
while ($orders_status = tep_db_fetch_array($orders_status_query)) {
$status_id = $orders_status['orders_status_id'];
$status_name = $orders_status['orders_status_name'];
$status_group = $orders_status['orders_status_group'];
}
That’s the basic code. I tried doing this to the above mentioned code:
while ($orders_status = tep_db_fetch_array($orders_status_query)) {
$status_id = $orders_status['orders_status_id'];
$status_name = $orders_status['orders_status_name'];
$status_group = $orders_status['orders_status_group'];
echo 'if (currentOption.val() == "' . $status_id . '") {
var optgroup = $("<optgroup/>");
optgroup.attr("label", "' . $status_group . '");
currentOption.wrapAll(optgroup);
}
';
}
What that did is basically created multiple Family of Doe. Instead I would like to somehow create only one Family of Doe and push Name and ID into it
1 Answer