DBookatay Posted February 5, 2011 Share Posted February 5, 2011 I have a script that pulls data from my dB based on the year selected from 2006 - 2011, and if no year is selected it automatically loads the current year, 2011. I have a css that changes the design of the "tab" based on the year selected, but how do I make it so that the "On" style reflects the current year tab if no year is selected? Confused yet? I created an image of what I mean as well as the php script. if ($_GET['date']) {$year = ($_GET['date']);} else {$year = date("Y");} $query = "select DISTINCT YEAR(sold_date) AS `sold_date` FROM Sold WHERE sold_date ORDER BY sold_date DESC"; $result = mysql_query($query); $numrows = mysql_num_rows($result); while($row = mysql_fetch_array($result)){ $year = $row['sold_date']; if ($_GET['date'] == $year) { $class = "On"; } elseif ($_GET['date'] != $year) { $class = ""; } $miniNav .= '<a class="'.$class.'" href="index.php?date='.$year.'">'.$year.'</a>'; } [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/226749-help-with-nav-tabs-and-css/ Share on other sites More sharing options...
Pikachu2000 Posted February 5, 2011 Share Posted February 5, 2011 Before the loop, if the $_GET var is empty, assign 2011 to it. if( empty($_GET['date']) ) { $_GET['date'] = 2011; } Link to comment https://forums.phpfreaks.com/topic/226749-help-with-nav-tabs-and-css/#findComment-1170133 Share on other sites More sharing options...
DBookatay Posted February 5, 2011 Author Share Posted February 5, 2011 Before the loop, if the $_GET var is empty, assign 2011 to it. if( empty($_GET['date']) ) { $_GET['date'] = 2011; } Wow that easy hunh? Thanks! Link to comment https://forums.phpfreaks.com/topic/226749-help-with-nav-tabs-and-css/#findComment-1170136 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.