Forum Moderators: coopster

Message Too Old, No Replies

PHP query confusion.

         

tonynoriega

3:45 pm on Jun 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am trying query my agents to see how many records that have entered to my lead registration database, and query that by the previous week...

so i can see how many they entered at any given day for the previous 7 days...

i keep getting errors...any insight is greatly appreciated.

thanks
_____________________________________________________________________

$query = "SELECT agent,COUNT(agent) FROM my_table GROUP BY agent
WHERE DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= entry_time";

eelixduppy

3:48 pm on Jun 11, 2007 (gmt 0)



>> i keep getting errors

Can you elaborate on what kinds of errors you are receiving?

Also, try something like this to see if it helps:


$query = "SELECT agent,COUNT(agent) FROM my_table WHERE DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= entry_time GROUP BY agent";

Habtom

3:50 pm on Jun 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A quick glance, WHERE comes first then GROUP by, no?

Habtom

>> eelixduppy, oops that was what I thought.

[edited by: Habtom at 3:52 pm (utc) on June 11, 2007]

tonynoriega

4:53 pm on Jun 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That was it... i didnt know "WHERE" had to come first... learn something new everyday.

Now, if i may continue...

What my agents want is to show how many records they entered for the previous 7 days, broken down by each day.

So it would kind of look like this i guess...
Would this involve an Array?

Day 1 2 3 4 5 6 7 ¦ Week
-------------------------------------------
AgentA 1 0 0 0 0 0 1 ¦ 2
AgentB 1 1 1 1 0 0 0 ¦ 4
-----------------------------------¦-------
Total 2 1 1 1 0 0 1 ¦ 6

tonynoriega

5:07 pm on Jun 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In addition, how could i eliminate a certain value from showing?

For instance, i have a field that is for "How did you hear about us?" and there is a value for "N/A" and i dont want that to be displayed in the table...

possible?

barns101

8:26 pm on Jun 11, 2007 (gmt 0)

10+ Year Member



In addition, how could i eliminate a certain value from showing?

SELECT * FROM `table` WHERE `field` LIKE 'value' AND `other_field` NOT LIKE 'N/A';