Jump to content

Recommended Posts


// 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?

Link to comment
https://forums.phpfreaks.com/topic/224910-can-not-figure-out-this-date-query/
Share on other sites

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...

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.