Wayniac Posted January 2, 2010 Share Posted January 2, 2010 Any suggestions on how I might be able to switch from newest entries to youngest trees? I can't get it to change between them when the drop down menu's item is switched. Sorting Order</span><br> <select name="sort" class="textBox_center" id="sort" style="width:150px;"> <option value="1">Newest Entries<?php $result = mysql_query("SELECT * FROM album ORDER BY dtime DESC",$connect); ?></option> <option value="2">Youngest Trees<?php $result = mysql_query("SELECT * FROM album ORDER BY age DESC",$connect); ?></option> </select> Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted January 2, 2010 Share Posted January 2, 2010 start over Quote Link to comment Share on other sites More sharing options...
Stephen Posted January 2, 2010 Share Posted January 2, 2010 You could try something like: Sorting Order</span><br> <select name="sort" class="textBox_center" id="sort" style="width:150px;"> <option value="1" onclick="newestentries.display='block';youngesttrees.display='none'">Newest Entries</option> <option value="2" onclick="newestentries.display='none';youngesttrees.display='block'">Youngest Trees</option> </select> And have two sections that would correspond to this: <div id="newestentries" style="display: none"> <?php $result = mysql_query("SELECT * FROM album ORDER BY dtime DESC",$connect); while ($row = mysql_fetch_assoc($result)) { echo(" <a href=\"image_script.php?albumid=" . $row["albumid"] . "\">" . $row["title"] . "</a><br />"); } ?> </div> <div id="youngesttrees" style="display: none"> <?php $result = mysql_query("SELECT * FROM album ORDER BY age DESC",$connect); while ($row = mysql_fetch_assoc($result)) { echo(" <a href=\"image_script.php?albumid=" . $row["albumid"] . "\">" . $row["title"] . "</a><br />"); } ?> </div> Not sure if that's what you're looking for though. Quote Link to comment Share on other sites More sharing options...
Wayniac Posted January 2, 2010 Author Share Posted January 2, 2010 Thank you so much Stephen, this works better then amazing! Here is the working updated code with a few changes. Sorting Order</span><br> <select name="sort" class="textBox_center" id="sort" style="width:150px;"> <option value="1" onclick="newestentries.style.display='block';youngesttrees.style.display='none'">Newest Entries</option> <option value="2" onclick="newestentries.style.display='none';youngesttrees.style.display='block'">Youngest Trees</option> </select> <div id="newestentries" style="display: block"> <?php $result = mysql_query("SELECT * FROM album ORDER BY dtime DESC",$connect); while ($row = mysql_fetch_assoc($result)) { echo(" <a href=\"read_more.php?albumid=" . $row["albumid"] . "\">" . $row["title"] . "</a><br />"); } ?> </div> <div id="youngesttrees" style="display: none"> <?php $result = mysql_query("SELECT * FROM album ORDER BY age DESC",$connect); while ($row = mysql_fetch_assoc($result)) { echo(" <a href=\"read_more.php?albumid=" . $row["albumid"] . "\">" . $row["title"] . "</a><br />"); } ?> </div> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.