DBookatay Posted January 19, 2011 Share Posted January 19, 2011 // Nav Tabs $query = "select DISTINCT YEAR(sold_date) FROM Sold"; $result = mysql_query($query); $numrows = mysql_num_rows($result); while($row = mysql_fetch_array($result)){ $year = substr($row['sold_date'], 0, -6); $navTab .= '<a class="miniTabOn" href="index.php?date='.$year.'">'.$year.'</a>'; } I am trying to create a link for each year of items in my database, yet the text is not showing up... The "nav tab" is, because I can see the background image from the class="miniTabOn". Can anyone spot an error? Quote Link to comment https://forums.phpfreaks.com/topic/224910-can-not-figure-out-this-date-query/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 19, 2011 Share Posted January 19, 2011 You aren't selecting the sold_date column, so $row['sold_date'] doesn't exist. Use an alias for the YEAR(sold_date) term in your query and reference that alias name in your php code. Quote Link to comment https://forums.phpfreaks.com/topic/224910-can-not-figure-out-this-date-query/#findComment-1161706 Share on other sites More sharing options...
DBookatay Posted January 19, 2011 Author Share Posted January 19, 2011 You aren't selecting the sold_date column, so $row['sold_date'] doesn't exist. Use an alias for the YEAR(sold_date) term in your query and reference that alias name in your php code. Would you mind explaining? I dont understand... Quote Link to comment https://forums.phpfreaks.com/topic/224910-can-not-figure-out-this-date-query/#findComment-1161710 Share on other sites More sharing options...
DBookatay Posted January 19, 2011 Author Share Posted January 19, 2011 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/224910-can-not-figure-out-this-date-query/#findComment-1161719 Share on other sites More sharing options...
PFMaBiSmAd Posted January 19, 2011 Share Posted January 19, 2011 Search for 'alias' on this page - http://dev.mysql.com/doc/refman/5.1/en/select.html When someone mentions a basic technical term related to programming that you don't understand, it is always best if you consult the original documentation that defines what was mentioned. You will get a more complete and concise explanation, often with examples, compared to just a portion of the information in a brief and quickly typed reply. Quote Link to comment https://forums.phpfreaks.com/topic/224910-can-not-figure-out-this-date-query/#findComment-1161762 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.