I am having a heck of a time trying to get 2 arrays of info into something I can work with. I have checked my past posts and others and still cannot seem to solve this.
I have several tables with states and video counts selected for each state. What I am trying to end up with looks like this. (arrays.png)
http://www.izzit.org/arrays.png
I have 1 query with all the info (which I could not even get close to what I want).
SELECT s.Id, s.StateName AS State,
Count(*) AS FAV_Count
from table1 as f
join table2 as a on f.ContactId = a.ContactId
join table3 as s on a.State = s.StateAbbreviation
JOIN table4 as i ON f.ItemId = i.Id
WHERE date(f.DateAdded) BETWEEN '2011-05-08' and '2011-05-14'
GROUP BY a.State, f.ItemId
ORDER BY a.State, i.SKU
This gets all the data I need to make my table(s).
(arrays2.bmp)
http://www.izzit.org/arrays2.bmp
With this query, I would like to iterate thru with a foreach and build the table (I already have the 1st row as a separate table, with the video SKU's [CC-VMD, CE-FPTP, etc]).
I just need to get the state abbreviation, then display the video count below each of the videos.
I would be OK with 2 separate queries and tables. 1st for the states on the left, and 2nd for the video counts. I can then iterate thru and build both tables.
Thanks for the help,
D