|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
help with reports
I need to run a report that will list every month in a spacific year and also list every rep and the number of contacts the have for each month any suggestions
|
|
#2
|
|||
|
|||
|
RE: help with reports
is this info stored in a database? if so, let's see the table layout...then i can show you a query to get that info.....
|
|
#3
|
|||
|
|||
|
RE: help with reports
yes it is in a Msql database. I have 2 tables.
Table1 Reps id,r_code,fname,lname Table2 delegates id,t_stamp,fname,spouse,lname,address,city,state,z ip,phonenumber,rep,ccat,status,email,notes I need to use r_code for the reps and t_stamp for the months. |
|
#4
|
|||
|
|||
|
RE: help with reports
does delgate.rep = reps.r_code ??
|
|
#5
|
|||
|
|||
|
RE: help with reports
yes it does
|
|
#6
|
|||
|
|||
|
RE: help with reports
This will pull all the info sorted by t_stamp and then the r_code...
select reps.*, delegates.* from reps,delegates where delegates.rep=reps.r_code order by t_stamp, r_code |
|
#7
|
|||
|
|||
|
RE: help with reports
that works good but i need some thing like this
|jan|feb|march|april|may|june|july|aug|sept|oct|no v| ---------------------------------------------------- Rep1 |15| Rep2 |20| Rep3 |10| |
|
#8
|
|||||
|
|||||
|
RE: help with reports
Assuming that the t_stamp field is a mysql timestamp..i would do something like this in php:
php Code:
Now, I haven't tested that, but it should give you an idea...after that runs, you will have all the data you need in a multi-dimensional array. Then, all you have to do is display it.... |
|
#9
|
|||
|
|||
|
RE: help with reports
Either i didn't get it or i'm not understanting how to display it all i get is
TP 10 AH 10 AH 10 AH 10 AH 10 AH 10 AH 10 AH 10 AH 10 AH 10 AH 10 AH 10 AH 10 AH 10 AH 10 AH 10 AH 10 AH 10 AH 10 AH 10 AH 10 AH 10 AH 10 BH 10 BH 10 BH 10 BH 10 BH 10 BL 10 BL 10 BL 10 BL 10 BL 10 BL 10 CC 10 CC 10 CC 10 CC 10 CS 10 CS 10 CS 10 CS 10 CS 10 NH 10 NH 10 NH 10 NH 10 |
|
#10
|
|||
|
|||
|
RE: help with reports
ok i think i was telling you wrong what i need this to do is
list each month in the year across the top then list distinct each rep across the left hand side then tell how many contacts they recieved for each month. |
|
#11
|
|||
|
|||
|
RE: help with reports
Like I said, you still need to work out the display system...here is some pseudo code...
Code:
start table
new row
display one empty <td></td>
for i = 1 to 12
{ <td>convert i to monthname</td> }
end row
foreach rep {
new row
echo <td>$rep</td>
for i = 1 to 12
{ if isset($report[$i]["$rep"]) echo <td>$report[$i]["$rep"]</td>
else echo <td>0</td>
}
end row
}
end table
|
|
#12
|
|||
|
|||
|
RE: help with reports
Sorry I'm Still not able to get this to work. Is there anything i can do to help.
|
|
#13
|
|||
|
|||
|
RE: help with reports
Where are you having a problem? Can we see some code that you are not able to get to work?
|
|
#14
|
|||
|
|||
|
RE: help with reports
<?php
require_once ("./application/backend.php"); // connect to db $connection = @mysql_connect("$authlib->server", "$authlib->db_user", "$authlib->db_pass") or die("Couldn't connect."); $db = @mysql_select_db($authlib->database, $connection) or die("Couldn't select database."); $query = "select reps.r_code, UNIX_TIMESTAMP(contacts.t_stamp) as getmonth, contacts.id from reps,contacts where contacts.rep=reps.r_code order by t_stamp, r_code"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { $month = strftime("%m", $row['getmonth']); $rep = $row['r_code']; if(isset($report[$month]["$rep"])) { $report[$month]["$rep"]++; } else { $report[$month]["$rep"] = 1; } } // start table echo "<TABLE ALIGN="CENTER" CELLPADDING="3" WIDTH="100 %" BORDER="0">"; echo "<TR>"; // new row echo "<td></td>"; for i = 1 to 12 { <td>convert i to monthname</td> } // end row foreach rep { echo "<td>$rep</td>"; for i = 1 to 12 { if isset($report[$i]["$rep"]) echo <td>$report[$i]["$rep"]</td> else echo <td>0</td> } // end row echo "</tr>"; } // end table echo "</table>"; ?> |
|
#15
|
|||
|
|||
|
RE: help with reports
the proper syntax for for loops is:
for($var = 0; $var < somenumber; $var++) foreach loops: foreach($something as $asmallerpart) |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > help with reports |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |