Grid will not render Total column from request form with code below

QuestionsGrid will not render Total column from request form with code below
Andy asked 5 years ago

Any help would be great on why this will not render the total column. If I hard code a date for the wkstart and wkend it works fine on the page. When I pass a variable it just shows 0’s for all totals.

date_default_timezone_set(“America/New_York”);
$wkstart = $_REQUEST[“start_date”];
$wkend = $_REQUEST[“end_date”];
$wkstart = date(“Y-m-d”, strtotime($wkstart));
$wkend = date(“Y-m-d h:i:s”, strtotime($wkend));

$g->select_command = “select students.AddressofresidenceCity,
students.AddressofresidenceState,
students.AddressofresidenceStreet,
students.AddressofresidenceStreet2,
students.AddressofresidenceZip,
students.BirthDate,
students.BirthplaceCity,
students.BuildingGrade,
students.CalledName,
students.CountyCode,
students.Disadvantagement,
students.DistrictAdmissionDate,
students.DistrictOfResidence,
students.DistrictWithdrawDate,
students.EffectiveStartDate,
students.EMISId,
students.EMISSituationId,
students.FamilyGroupName,
students.FirstName,
students.FiscalYearBegan9th,
students.Gender,
students.HomelessStatus,
students.Homeroom,
students.HomeroomTeacher,
students.Lastname,
students.LastNameSuffix,
students.MailingAddressCity,
students.MailingAddressState,
students.MailingAddressStreet,
students.MailingAddressStreet2,
students.MailingAddressZip,
students.MiddleName,
students.PrimaryContactCity,
students.PrimaryContactEmail,
students.PrimaryContactFirstName,
students.PrimaryContactHomePhone,
students.PrimaryContactLastName,
students.PrimaryContactMiddleName,
students.PrimaryContactMobilePhone,
students.PrimaryContactNameSuffix,
students.PrimaryContactRelationshipcomments,
students.PrimaryContactState,
students.PrimaryContactStreet,
students.PrimaryContactStreet2,
students.PrimaryContactTitle,
students.PrimaryContactType,
students.PrimaryContactZip,
students.Program,
students.Section504Plan,
students.StateStudentID,
students.Status,
students.StudentEmail, students.StudentNumber, IFNULL(round(sum(TimestampDiff(minute, Time_Start, Time_End))/60,2), 0) as TotalHours from students left join attendance on students.StudentNumber = attendance.StudentNumber and students.status = ‘active’ and time_start between ‘” . $wkstart . “‘ and ‘” . $wkend . “‘ Group by students.StudentNumber”;
$g->table = “attendance”;

2 Answers
Abu answered 5 years ago

You need to preserve posted data in session. Refer this faq:

http://www.phpgrid.org/faqs/#20

Andy answered 5 years ago

So I loaded the request form variables to the session and it still didn’t work? You said in the example not to use the session variables, but just use the variable in the SQL. I guess I must be missing something?

 

date_default_timezone_set(“America/New_York”);
$wkstart = $_REQUEST[“start_date”];
$wkend = $_REQUEST[“end_date”];
$wkstart = date(“Y-m-d”, strtotime($wkstart));
$wkend = date(“Y-m-d h:i:s”, strtotime($wkend));
//echo $wkstart;
//echo $wkend;
session_start();
$_SESSION[“wkstart”] = $wkstart;
$_SESSION[“wkend”] = $wkend;
$wkstart = $_SESSION[“wkstart”];
$wkend = $_SESSION[“wkend”] ;

Your Answer

1 + 7 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?