Page 1 of 1

Work question/problem/issue.. inserting variables.. Drupal

Posted: Sat Nov 06, 2010 12:44 pm
by erickambestad
I’m having an issue with a reporting project at work. I’m fairly new to PHP but I’m good with HTML and MySQL and I’m trying to do something a little beyond my PHP knowledge so I could use a little help. This is a Drupal site so PHP is a must.

Here is my issue:
I need to take a SELECT COUNT query and report the count within certain dates and display it on a table on the page. I have the query written with variables in place and ready to go.
I have a MySQL table with 5 pieces of info in it.
Table: ID(PK, auto-incremented), campaign_name, from_date, to_date, decription

I already have the form built and working to insert values in to these fields, which I will do manually so that’s not the issue.
The thing that I need is a page with all of the campaign names/descriptions listed and linked to their specific count page… or even display it on the current page. So, by clicking on a campaign name it will insert the dates of that campaign in to the MySQL query and display the count.
How can I fully automate this whole process? (other than the initial data entry) I don’t want to have to create a new page for each campaign.. it needs to be automatic so that when a campaign is entered in to the database you can go to the report page and the link will be ready to click and find the count.
That’s really it.. I’m not looking for anyone to code it for me, or anything like that. I just need to know what to do to make this efficient and work the way it is supposed to. I know this issue would not be hard for someone who is good at PHP or even just development in general so any help is appreciated.

Thanks in advance!

Re: Work question/problem/issue.. inserting variables.. Drup

Posted: Mon Nov 08, 2010 8:00 am
by alex.barylski
When you say 'count' what count are you refering too? It sounds as though you want to list a table of records in a paginated fashion, but when the campaigns are clicked, they are to show details of the campaign, something to do with count???

I assume you have the basics of a module setup? How did you confiure the routing, that is the URI which will invoke the specific action of a module?

Or did you use CCK and Views?

Cheers,
Alex

Re: Work question/problem/issue.. inserting variables.. Drup

Posted: Mon Nov 08, 2010 12:36 pm
by erickambestad
So, I've changed what I need a little bit. First of all I'm not using any modules for this.. no cck, views, nothing custom.. I don't have any experience with module development and they really don't do what I'm trying to do here I think. Since I have some PHP experience and you can create PHP pages just as easy as anything I am doing it this way.

In a nutshell I need to take the information located in the table and print it (easy so far).. I have 4 columns: name, from_date, to_date, and description. I want to loop through everything in the table.. (and starting here is where I'm having trouble).. each time through it needs to print those 4 columns and add a fifth column. The count column where each time through it will insert those from and to_dates of each row in to my query and give me the count of fans added between those dates and print that in that 5th column.

Note: I have the query with variables inserted all ready to go so that's no issue.

I'm sure there is a much easier way to do this than I am explaining so if anybody knows of a way, do share.. I'm not set on this exact method. I just need a 5th column with the count of fans from "from_date" to "to_date"... I hope this is actually easy and I'm missing something.