Jump to content

how can i pass the selected value date to another page?


Recommended Posts

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> &nbsp;  &nbsp;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'); ?>">` ? 

Link to post
Share on other sites

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 by Barand
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.