Forum Moderators: coopster

Message Too Old, No Replies

Newbie.While Looping.

trying to build two tables to display data...

         

tonynoriega

8:26 pm on Aug 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This function builds a single table that displays a small weekly calendar to display how many records have been entered into my dbase talbe...

i need to show another table with separate queries above this one...

i tried to just duplicate the table, using a while statement, just to make sure i can display two tables, with slightly different queries, but to no avial....would anyone be able to show me the correct syntax to do that?
______________________________________________________________________

function leadstablereport_display_addon() {
$security_admin = login::loginCheck('Admin', true);
$security_agent = login::loginCheck('Agent', true);
if ($security_admin === true ¦¦ $security_agent === true) {
global $config, $conn;
require_once($config['basepath'] . '/include/misc.inc.php');
$misc = new misc();
$ts = time();
$todays_date = date("F j Y");
$current_date = date("F j");
$seconds = 24 * 60 * 60;

$six_days = 6 * $seconds;
$five_days = 5 * $seconds;
$four_days = 4 * $seconds;
$three_days = 3 * $seconds;
$two_days = 2 * $seconds;
$one_days = 1 * $seconds;

$end_date = date("F j Y", ( $ts - $six_days));
$seven_daysago = date("F j", ( $ts - $six_days));
$six_daysago = date("F j", ( $ts - $five_days));
$five_daysago = date("F j", ( $ts - $four_days));
$four_daysago = date("F j", ( $ts - $three_days));
$three_daysago = date("F j", ( $ts - $two_days));
$two_daysago = date("F j", ( $ts - $one_days));
$one_daysago = date("F j", ( $ts - $one_days));

$sql = 'SELECT nhm_associate, COUNT(nhm_associate) AS weekscount, (SELECT COUNT(*) FROM registration_table WHERE DATE_SUB(CURDATE(),INTERVAL 2 DAY) <= entry_time GROUP BY nhm_associate) AS yesterday, (SELECT COUNT(*) FROM registration_table WHERE DATE_SUB(CURDATE(),INTERVAL 6 DAY) <= entry_time) AS totalcount FROM registration_table WHERE DATE_SUB(CURDATE(),INTERVAL 6 DAY) <= entry_time GROUP BY nhm_associate ORDER BY entry_time';

// EXECUTE
$recordSet = $conn->Execute($sql);

// CHECK IF ERROR
if ($recordSet === false) {
$misc->log_error($sql);
}
// KEEP READING TILL THE END

$display .='<table width="100%" border="1" style=border-collapse:collapse; border-style:solid;>'; // start your table before
$display .='<tr><td colspan="9"><h1 align="center">Registration Leads Entered Week of: ' . $end_date . ' to ' . $todays_date . '</h1></td></tr>';
$display .='<tr><td></td><td>' . $seven_daysago . '</td><td>' . $six_daysago . '</td><td>' . $five_daysago . '</td><td>' . $four_daysago . '</td><td>' . $three_daysago . '</td><td>' . $two_daysago . '</td><td>' . $current_date . '</td><td>Weeks Total</td></tr>';

while (!$recordSet->EOF) {
$tc = $misc->make_db_unsafe ($recordSet->fields['totalcount']);
$nhma = $misc->make_db_unsafe ($recordSet->fields['nhm_associate']);
$wc = $misc->make_db_unsafe ($recordSet->fields['weekscount']);
$c_today = $misc->make_db_unsafe ($recordSet->fields['cal_today']);
$c_yesterday = $misc->make_db_unsafe ($recordSet->fields['yesterday']);

$display .='<tr><td>' . $nhma . '</td><td>' . $c_six . '</td><td>' . $c_five . '</td><td></td><td></td><td></td><td>' . $c_yesterday . '</td><td>' . $c_today . '</td><td>' . $wc . '</td></tr>';

// GO GET THE NEXT ONE
$recordSet->MoveNext();
}

$display .='<tr><td>Total Registrations</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>' . $tc . '</td><tr>';
$display .='</table>'; // close your table after

} else {
// DISPLAY A WARNING TO THE PAGE AS ADMIN/AGENT IS NOT LOGGED
$display .= 'YOU ARE NOT AUTHORIZED TO VIEW THIS PAGE. PLEASE GO TO THE BOTTOM OF THE PAGE AND LOG IN!';
$recordSet->MoveNext();
}
return $display;
}

jatar_k

8:36 pm on Aug 20, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



did you take a look at the source? Maybe there was an html reason the 2 tables wouldn't show.

or did you get some kind of error?

tonynoriega

9:19 pm on Aug 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



i figured it out....thanks

[edited by: tonynoriega at 9:59 pm (utc) on Aug. 20, 2007]

jatar_k

9:59 pm on Aug 20, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



is it a non displayed parse error?

tonynoriega

10:06 pm on Aug 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, i realized i didnt need a while statement, and just rewrote the query and the output, dropped it above the original statement and it works just fine....

jatar_k

10:07 pm on Aug 20, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



strange that you would get a blank page

glad you fixed it