ramiwahdan Posted March 15, 2020 Share Posted March 15, 2020 Hi, I have a form that has start date and end date in the form plus link to generate a report. the link will go to other page but i need to be able to get the values of the 2 date fields from the first page. how to do that? Quote Link to comment Share on other sites More sharing options...
ramiwahdan Posted March 15, 2020 Author Share Posted March 15, 2020 16 minutes ago, ramiwahdan said: Hi, I have a form that has start date and end date in the form plus link to generate a report. the link will go to other page but i need to be able to get the values of the 2 date fields from the first page. how to do that? <?php while($row=mysqli_fetch_assoc($result)) { $userid = $row['OracleID']; $name = $row['StaffName']; $des = $row['Des']; ?> <tr> <td><?php echo $userid ?></td> <td><?php echo $name ?></td> <td><?php echo $des ?></td> <td><input type="date" name="startdate"></td> <td><input type="date" name="enddate"></td> <td><a href="reportbyidbydate.php?GetID=<?php echo $userid?>&startdate=<?php echo $startdate?> ">Print Full Report</a></td> </tr> <?php } ?> i am trying to use the get method but for startdate i am not sure how to reference it from the input field Quote Link to comment Share on other sites More sharing options...
requinix Posted March 15, 2020 Share Posted March 15, 2020 Use a form, not a link. Quote Link to comment Share on other sites More sharing options...
ramiwahdan Posted March 15, 2020 Author Share Posted March 15, 2020 (edited) 1 hour ago, requinix said: Use a form, not a link. I am using the link to get the exact information of specific user in the db, from that I will generate a report of attendance. I am trying to have 2 fields of dates (Start and End) so that then i will go to next page and use that information to get the reports based on the selected dates. from 3-1-2020 to 3-15-2020, this will generate report of attendance from 3-1-2020 until 3-15-2020 instead of getting all dates. That is my aim. so i am using the link to refer to the right user by his id. Is there a better way. screenshot attached, this is getting all dates i need the admin to put 2 dates "From and To" then generates based on selection. Edited March 15, 2020 by ramiwahdan more info Quote Link to comment Share on other sites More sharing options...
ramiwahdan Posted March 15, 2020 Author Share Posted March 15, 2020 (edited) 31 minutes ago, ramiwahdan said: I am using the link to get the exact information of specific user in the db, from that I will generate a report of attendance. I am trying to have 2 fields of dates (Start and End) so that then i will go to next page and use that information to get the reports based on the selected dates. from 3-1-2020 to 3-15-2020, this will generate report of attendance from 3-1-2020 until 3-15-2020 instead of getting all dates. That is my aim. so i am using the link to refer to the right user by his id. Is there a better way. screenshot attached, this is getting all dates i need the admin to put 2 dates "From and To" then generates based on selection. i solved it with only one problem, if i choose 3-1-2020 to 3-15-2020 i get only one record excluding the 3-15-2020 but i put 3-1-2020 to 3-16-2020 i get both, there is 1 day difference why is that? code : $sdate1 = $_POST['sdate']; $edate1 = $_POST['edate']; $query = "select * from attendance_records where OracleID = '".$userid."' and isdone= '".$isdone."' and ClockingInDate >= '".$sdate1."' and ClockingOutDate <= '".$edate1."'"; $result = mysqli_query($con, $query); where clockingindate is start date in DB, clockingoutdate is end date in DB. sdate and edate are taken from admin user in the form. Edited March 15, 2020 by ramiwahdan more clear info Quote Link to comment Share on other sites More sharing options...
requinix Posted March 15, 2020 Share Posted March 15, 2020 I'm not sure I followed that question but I think the right reply is something like "if you enter 3-15-2020 as the date then what is the time?" Quote Link to comment Share on other sites More sharing options...
ramiwahdan Posted March 15, 2020 Author Share Posted March 15, 2020 14 minutes ago, requinix said: I'm not sure I followed that question but I think the right reply is something like "if you enter 3-15-2020 as the date then what is the time?" that is what i suspected but how to get the timestamp from date picker in php forms then? Quote Link to comment Share on other sites More sharing options...
requinix Posted March 15, 2020 Share Posted March 15, 2020 Remember what I said about using a form? Use a form. 1 Quote Link to comment Share on other sites More sharing options...
ramiwahdan Posted March 15, 2020 Author Share Posted March 15, 2020 1 minute ago, requinix said: Remember what I said about using a form? Use a form. yes i did, I am using a form but putting the type to date gives me to pick dates only with no time. code: <form action="#" method="post"> <input type="date" name="sdate" required="required"></input> <input type="date" name="edate" required="required"></input> <input type="submit" name="saveit" value="Generate"></input> </form> Quote Link to comment Share on other sites More sharing options...
Barand Posted March 15, 2020 Share Posted March 15, 2020 Sounds like you are comparing datetimes against date only values, in which case you need to compare just the date portions of the datetime values ... WHERE DATE(ClockingInDate) <= '$edate1' AND DATE(ClockingOutDate) >= '$sdate1' 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.