How to Retrive data of the Previous month with Loop
I'm using a php & MySQL. In the MySQL table name Employee. it has 3 fields EmpYear, EmpName, EmpDateAdded where data are records from january to december 2008. On the otherhard, In my php code i created also a table with 4 columns ColYear, ColName, ColDateAdded, ColPrevYear. My concern is on the ColPrevYear, how do i code in php to get the data in fieldScore to display in ColPrevYear assuming that i am now viewing data for the month of July and i want to display in ColPrevYear the last month(June). However, if no year found for the month of June, it will loop back on the next previous months until score is found.
Anybody please help me with this...
Thanks in advance.
Re: How to Retrive data of the Previous month with Loop
You can achieve this in one of Several ways ...
One way is to build an array using a numeric index as you fetch results from your data source. Then as you build your html code, use $yourArray[$i - 1] to access the previous element in your array.
Another way is to store off the currently fetched data in a variable and then refer back to that variable as "previous".
|Tags: mysql, php, retrive data|
|Thread Tools||Search this Thread|
|Similar Threads for: "How to Retrive data of the Previous month with Loop"|
|Thread||Thread Starter||Forum||Replies||Last Post|
|How to retrieve previous iPhone data such as contacts through icloud||joey1408||Portable Devices||2||16-01-2012 12:34 PM|
|How to get a summarized sheet of all the data sheets of a month||Kindle||Windows Software||5||05-04-2011 06:47 PM|
|How to select previous month's date?||Saaz||Software Development||3||14-11-2009 02:07 PM|
|How to create excel graph data for a month in Windows Vista||AK_Chopra||Windows Software||2||04-06-2009 07:58 PM|
|How much Data you download per month ?||Shantanu12||India BroadBand||8||19-01-2009 09:46 AM|