This is obviously not a new problem, but I'm pretty new to all of this and I can't figure out how to make the droplists for numeric data form with intetegers rather than strings.
Can anyone help me?
Code: Select all
<FORM ENCTYPE="application/x-www-form-urlencoded" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<?
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Build and populate the droplists by using an array of column names.
- Distinct values from each column in the EventCombMT table will be used to create a droplist.
- To add or remove a droplist, edit the $columns variable.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
//~~~~~ loop through the array creating a droplist of ~~~~~//
//~~~~~ distinct values for each column in the array ~~~~~//
foreach( $columns as $temp) {
//set up the query
$query = "SELECT DISTINCT $temp FROM EventCombMT ORDER BY $temp;";
$result = odbc_exec($connectionstring, $query);
//now build the droplists for each element in the array in the lines below
?>
<select NAME="<?=$temp?>">
<option VALUE="">All <?=$temp?>s</option>
<?php
// create a droplist element for each item in the array
while(odbc_fetch_into($result, $row)) {
// if this droplist element ($row[0]) was passed as a parameter($_GET[$temp]), set the option as selected and give it a distinctive appearance.
if (strtoupper($_GET[$temp]) == strtoupper($row[0])) {
print " <option value='".$row[0]."' selected='selected' style='background-color: white;font-weight:bold;color:red;'>".ucwords($row[0])."</option>\n";
} else {
print " <option value='".$row[0]."'>".ucwords($row[0])."</option>\n";
}
}
?>
</select>
<?
}
?>
<INPUT type="submit" value="Apply Filter">
</form>