php - Using Option Box to Filter Data -


i have option box filters data displayed on page. data table has information pertains cycle. $row_recordset2 way me view unique cycles in table (e.g. spring, fall, winter, spring) , filter in option box.

select distinct gpa.`cycle' gpa order gpa.id desc 

so option box give me cycle , show data.

<select name="selcycle" id="selcycle" onchange="formfilter.submit()"> <option value="%">all cycles</option> <?php {   ?> <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 data filtered correctly have display data (all cycles) , select cycle 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, gpa  gpa.cycle %s getsqlvaluestring($varcycle_recordset3, "text") 

i prefer latest id default page user being able switch cycles. i'm sure has default value set % or maybe using statement incorrectly gpa.cycle %s. i've tried gpa.cycle = %s instead of , no data displays on page load. of course option box display current cycle , match cycle in option box.


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -