Ok, I'm pretty new to PHP, so please be gentle with me :-)
The page that I'm working on shows events listings by date. When the user initially comes to the page, all events that are in the future show on a results table. Said another way, all past events are already filtered out. By default, the events are shown in date order.
The page has drop down menus to filter the results further. The drop down menus are dynamic from the Filemaker database, and they only show data from events in the future (not the past). The filter at issue here is the one for the Type of Event (conference, webinar, etc).
On Filemaker, the data is in just one table - no related table, no portals, etc. I'm working on the KISS principle.
The dynamic drop down menus work just fine in terms of searching and filtering the data, but I just have one problem with them -> they do not display the options in alphabetical order. I would think that some sort( ) somewhere would 'sort' things out (bad pun, I know, but I've been at this for a while), but I can't make it work.
I cannot find any logic as to how they are currently sorted. I unsorted the records and changed the entries to numbers, and they now come up in this order: 8, 2, 3, 18, 13, 17, 5, 14, 21. And that order does not correlate with the order for any other field. It's about as logical as the winning lottery numbers.
I'm using Filemaker 12. And the code that I'm using below.
My Grandfather use to say that most solutions are 'awfully simple' or 'simply awful'. I'm hoping for the former.
Many many thanks.
Snowball a/k/a Cin
<form name="form1" id="form1" action="home_results_new.php" method="post">
<p id="form1">
<br />
<b>Type:</b>
<select name="type" style="width:200px;">
<option value="*">Select a Type</option>
<?php
//foreach ($valueListb as $myvalueb)
{
?>
<?php
$displayedType = array();
sort($LineItems2_result->getRecords());
foreach($LineItems2_result->getRecords() as $LineItems2_row) {
$my_type = $LineItems2_row->getField('type');
if (in_array($my_type, $displayedType)) {
// already seen it
continue;
}
?>
<option value="<?php echo $my_type; ?>"><?php echo $my_type; ?></option>
<?php //}
?>
<?php
$displayedType[] = $my_type;
}
?>
</select>