Forum Moderators: coopster

Message Too Old, No Replies

PHP and MySQL .Generating a Printer Friendly Report?

         

tonynoriega

9:01 pm on Jun 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a PHP based registrtion form that submits approx. 30 fields to a MySQL dbase.

What i am trying to do is extract that data and generate a report.

i.e

i have 30 records total, but only 15 of them were entered by Agent "B"

i know how to pull the data and display it, but am not sure how i would count the entries to show the number "15"?

anyone got a tip?

eelixduppy

9:21 pm on Jun 7, 2007 (gmt 0)



You have to use count() [dev.mysql.com]. If you need further assistance, give the query and we'll try to get it working :)

tonynoriega

6:17 pm on Jun 8, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, here is what i have and what i am trying to do...( i am a PHP newbie, keep in mind) I just have a count of how many registration leads each agent has entered. I also have a field in my database that is called "lead_date" which is basically a now() function to capture the exact date they submitted the lead. What i need to do is create this report on a weekly basis. So somehow i have to input into this function a 7 day time frame...so that no matter when i bring up this report, it goes back 7 days.... im totally lost on how to implement that...?

function weekly_report() {
$security_admin = login::loginCheck('Admin', true);
$security_agent = login::loginCheck('Agent', true);
if ($security_admin === true ¦¦ $security_agent === true) {

$query = "SELECT associate, COUNT(associate) FROM registration_table GROUP BY associate";

$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result)){
$display .='There are '. $row['COUNT(nhm_associate)'] .' '. $row['nhm_associate'] . ' items.<br />';

}
} else {
// DISPLAY A WARNING TO THE PAGE AS ADMIN/AGENT IS NOT LOGGED
$display .= 'YOU ARE NOT AUTHORIZED TO VIEW THIS PAGE.';
}
return $display;
}

coopster

2:42 am on Jun 13, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Hi tonynoriega, here is a post from last year that shows how to View results where date less than 14 days old [webmasterworld.com]. The thread is quite detailed and should get you started off in the right direction.