473,385 Members | 1,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

New Row for each Year?

I have a database with records assigned to a year (2011, 2010, 2009, etc...)
Each year may have up to three records assigned to it.
How can I display a table to put each year on its own line (row)?

SO for 2011, display the three records
New row
2010, display the three records, etc...

Any help would be appreciated.

Thank you!
Feb 16 '12 #1
3 1661
Rabbit
12,516 Expert Mod 8TB
Don't write a break or similar HTML element to the document until there's a change in the year field.
Feb 16 '12 #2
Thanks Rabbit-
I guess my question is, how do I determine when it changes year?

CODE:
Expand|Select|Wrap|Line Numbers
  1. $query = "SELECT * FROM tblProductionsMaster where ProductionYear < Year(now()) AND ProductionActive = 1 ORDER BY ProductionYear DESC";
  2. $result=@mysql_query($query);
  3. if ($result) {
  4.     echo '<tr>
  5.             <td style=\"padding-left: 10px;\">
  6.                 <table border=0 width="100%" bgcolor=#ffffff>';
  7. $columnNum = 0;
  8. while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
  9. if($columnNum == 0)  {
  10. echo "<tr>\n";
  11. echo "<td valign=bottom align=center>
  12.         <table width=266 border=0 bgcolor=#ffffff>
  13.             <tr>
  14.                 <td align=center><a href=\"production_detail.php?pid=$row[ProductionID]\"><img src=images/logos/$row[ProductionLogoSmall] border=0></a></td>
  15.             </tr>
  16.             <tr>
  17.                 <td class=PastSeasonsGrid align=center><b>$row[ProductionName]</b></td>
  18.             </tr>
  19.             <tr>
  20.                 <td class=PastSeasonsGrid align=center>$row[ProductionYear]</td>
  21.             </tr>
  22.             <tr><td><br></td></tr>
  23.         </table>
  24.         </td>\n";
  25. if($columnNum == 2) {
  26. echo "</tr>\n";
  27. $columnNum = 0;
  28. }
  29. else
  30. $columnNum++;
  31. }}
  32.  
Feb 16 '12 #3
Rabbit
12,516 Expert Mod 8TB
Just store the year in a variable, when you read a new record, check if the year is different. If it is, write a break, and store the new year.
Feb 16 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: .:mmac:. | last post by:
I have to update a page every week. I get the page ahead of time so I used the "scheduled includes" webbot in Frontpage only to find that I would have to refresh the page every week to have it...
4
by: Wayne B. Stanley | last post by:
I have a database with records dating back to the year 2001 I want to know how many of each Assembly was tested per year I have fields : TestDate AssemblyNo I am new to access but was able to...
14
by: Alan | last post by:
Hi everyone! I'm trying to produce a periodic financial report on projects from various departments. My database is set up with the tables tblDepartment, tblProjects, tblPeriods, and tblBudgets...
18
by: Bruno Baguette | last post by:
Hello, I have to design a table wich will store some action reports. Each report have an ID like this 1/2004, 2/2004, ... and each years, they restart to 1 (1/2004, 1/2005, 1/2006,...). So, I...
11
by: Kevin | last post by:
I have a problem I'm trying to figure out how to resolve in Access. I have a volunteer database for a project which occurs each year. Currently I have to go in and wipe out the data each year to...
11
by: cansnowboard | last post by:
I built a file management database which generates a file number based on the year. i.e. 2006-PRRS-13 The criteria was that each file should be unique. So I took the primary key, added one to...
38
tdw
by: tdw | last post by:
In my Orders database (which someone else created and I have been improving), when I enter a new order it generates a file number (i.e. 2007-0001) using an autonumber REC_ID field. I'll show you the...
1
by: medic3212 | last post by:
Greatings, I am a vbs newbie, about two months of class. I am working on a dispatching program which uses an incrementing call number. The call number is made up of two separate parts, the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.