Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sample code tutorial info

Status
Not open for further replies.

arcnon

Programmer
Aug 12, 2003
242
US
I am very new to asp.net and am looking for a tutorial/s to help me generate a webpage as follows.

---psudocode---
Code:
for (i = current.year; i >= 1999 ; i--){
    print <h1>i</h>;

    for (m = 1; m =< 12; m++){
         if (myDataArray = get_year_&_month_records(y,m)){
             print <h2>m</h2>;
             print myDataArray;
         }
    }
}

sub get_year_&_month_records{
    theArray[] = query db for records with matching year, month in asend order
    if (theArray > 0){
        return theArray;
    }
    return 0;
}
thanks for any direction you can give.
 
As opposed to looking to convert the above code, it may be best if you describe exactly what you are trying to do (if we simply convert the above, it may not be the most efficient way of producing the results).

Can you explain what you actually want to do and why?

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
I am not looking to convert the script it is sudo code. I was hoping to find a example of writing a sql call that is in a function/method/subroutine to return a set of records based on the year and the month sorted in asending order.

printing them out as we loop thru the years and months

i = year... sorry did a typo the y in the function call should be i not y
"t_year_&_month_records(y,m)"
m = month
 
So what you are trying to do is something like:

Jan 2000
All Records Here...

Feb 2000
All Records Here...

etc...?


----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
right, "All Records Here" is news articles, publications etc.
 
OK that's easy enough.

First you would select all your records from your database in ascending order (you can use the example from faq855-5662 for how to connect to you database).

Whilst in the first row of the reader, create a varibale to hold the month/name and create the header row for that month/year and the first child row belonging to the month.

Then, whilst looping through the reader you would just check the variable against the reader row month/year. If it is the same add a child row otherwise just do the same steps as above (i.e. set up a header row and the first child row).

As I said above, try using the example in the FAQ to connect to the db and return the results that you will actually be working with. We can then take it from there if you run into any problems.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
As you can see there are some months that dont have any entries. And you can have a variable amount of articles per month.

On a side note-- connecting to the database isn't the issue. I have 500,000 lines of cgi's that I have to convert to this crap. So I chose the easiest of the lot. It is 24 lines long.

-- Sample OUTPUT
News Articles for 2005

January
[date] test link

April
[date] test link
[date] test link

May
[date] test link
[date] test link
[date] test link

June
[date] test link
[date] test link
[date] test link

July
[date] test link


News Articles for 2004

June
[date] test link
[date] test link
[date] test link

November
[date] test link
[date] test link
[date] test link

December
[date] test link
[date] test link

News Articles for 2003

December
[date] test link
[date] test link
[date] test link

News Articles for 2002

January
[date] test link
[date] test link
[date] test link

Febuary
[date] test link
[date] test link

March
[date] test link
[date] test link
[date] test link

News Articles for 2001

January
[date] test link
[date] test link

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top