sashavalentina Posted April 13, 2021 Share Posted April 13, 2021 I have this function where i want to pass the month and year according to the date drop down that is chosen by the user. But can't seem to get the selected month and year. But instead, i got the month and year for now (which is April 2020). Can any one show me how can i achive this? I mean how can i pass the month and year selected to my `allreport-summary.php` page. It would be better if you guys can show me examples of codes on how can i implement this. Any help will be appreciated. Thank you so much. cheers! <div class="row"> <div class="col-4 my-auto"> <input type="month" id="month" class="form-control" value="<?php echo date('Y-m'); ?>"> </div> <div class="col-4 my-auto"> <select class="form-control" id="seller"> <option value="">Select All</option> <?php $sql = "SELECT * FROM sellers ORDER BY seller_registered"; $query = $conn->query($sql); while ($row = $query->fetch_assoc()) { ?> <option value="<?php echo $row['id'];?>"><?php echo $row['seller_fullname'];?></option> <?php } ?> </select> </div> <div class="col-4"> <button type="button" class="btn btn-info" onclick="loadreports();"> <i class="nc-icon nc-zoom-split"></i> </button> <a href="allreport-summary.php?month=<?php echo date('Y-m');?>"> <button type="button" class="btn btn-info" style="height: 40px;"> <i class="fa fa-file-excel-o"></i> Export All Report </button> </a> </div> how can i pass that `<a href="allreport-summary.php?month=<?php echo date('Y-m');?>">` according to the selection of ` <input type="month" id="month" class="form-control" value="<?php echo date('Y-m'); ?>">` ? Quote Link to comment https://forums.phpfreaks.com/topic/312464-how-can-i-pass-the-selected-value-date-to-another-page/ Share on other sites More sharing options...
Barand Posted April 13, 2021 Share Posted April 13, 2021 (edited) Form inputs need a name attibute <select class="form-control" id="seller" name="seller"> You can then retrieve it in the receiving page from $_POST['seller'] (or $_GET['seller'] if your form method is "GET") Anything in the query string is retrieved from $_GET array eg $_GET['month']. If you form method is POST, I would put the date in a hidden form input value so all you date will be in the $_POST array. Edited April 13, 2021 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/312464-how-can-i-pass-the-selected-value-date-to-another-page/#findComment-1585799 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.