I have an option box that filters the data to be displayed on the page. My data table has information that pertains to a cycle. $row_Recordset2 is just a way for me to view the unique cycles in my table (e.g. Spring, Fall, Winter, Spring) and is the filter in the option box.
SELECT DISTINCT gpa.`Cycle'
FROM gpa
ORDER BY gpa.ID DESC
So my option box would give me my Cycle and only show that data.
<select name="selCycle" id="selCycle" onchange="formFilter.submit()">
<option value="%">all cycles</option>
<?php
do {
?>
<option value="<?php echo $row_Recordset2['Cycle']?>"<?php if
($varCycle_Recordset3 == $row_Recordset2['Cycle']) {echo 'selected';} ?>><?
php echo $row_Recordset2['Cycle']?></option>
<?php
} while ($row_Recordset2 = mysql_fetch_assoc($Recordset2));
$rows = mysql_num_rows($Recordset2);
if($rows > 0) {
mysql_data_seek($Recordset2, 0);
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
}
?>
</select>
Right now the data is filtered correctly but I always have to display all the data (All Cycles) and then select the Cycle I would like to view.
$varCycle_Recordset3 = "%";
if (isset($_POST['selCycle'])) {
$varCycle_Recordset3 = $_POST['selCycle'];
}
mysql_select_db($database_ss, $ss);
$query_Recordset3 = sprintf("SELECT gpa.ID, gpa.Data,
FROM gpa
WHERE gpa.Cycle LIKE %s
GetSQLValueString($varCycle_Recordset3, "text")
I would prefer that the latest ID be the default for the page with the user being able to switch Cycles. I'm sure it has to do with the default value set to % or maybe I am using the Where statement incorrectly with gpa.Cycle LIKE %s. I've tried gpa.Cycle = %s instead of LIKE and then no data displays on page load. I of course would like the option box to display the current Cycle and match the Cycle in the option box.