如何使用按钮从选定的checboxes向另一个页面发送多个ID

时间:2018-05-13 08:09:22

标签: javascript php jquery html

在第一页上,如果某人选择了多个值,他将显示所选的值。然后,他将单击将链接到第二页的按钮。按钮保存第二页的选定值。

将保留所选值,第二页需要再次选择它们。第一页有复选框,第二页有单选按钮。但它是一个包含ID的链接。

一旦第一页和第二页的值保持不变,它将进入数据库以检查每个页面的值。如果值在数据库中,它将根据第一页和第二页值显示信息。

第一页(menu.php)

   <?php        
     if(isset($_POST['submit'])){
         if(!empty($_POST['penyakit'])) {
             // Counting number of checked checkboxes.
             $checked_count = count($_POST['penyakit']);
             echo "You have selected following ".$checked_count." option(s): <br/>";
             // Loop to store and display values of individual checked checkbox.
             foreach($_POST['penyakit'] as $selected) {
                        echo "<p>".$selected ."</p>"; 
             }
            }
            // echo "<a href='menu0.php?penyakit={$selected}' class='btn 
              btn-primary left-margin'>";
            //echo "<span class='glyphicon glyphicon-list'></span> Baca";
             // echo "</a>";
           }
         else{
             echo "<b>Please Select Atleast One Option.</b>";
         } 

    ?>  

第二页(menu0.php)

$selected = isset($_GET['selected']) ? $_GET['selected'] : die('ERROR: missing ID.');
<table class="table">
             <tbody id="myTable">
                <tr>
                      <div class="container">
                        <center><a class="list-unstyled-item list-hours-item d-flex" href='bfasM.php?selected={$selected}'><img border="0" src="img/bfas.jpg" width="250" height="100" ></a>
                        <h2 class="section-heading mb-4">
                        <span class="section-heading-upper">Sarapan Pagi </span>
                        </h2></center>
                      </div>
                </tr>
                <tr>
                    <div class="container">
                        <center><a class="list-unstyled-item list-hours-item d-flex" href="lunchM.php?selected={$selected}"><img border="0" src="img/lunch.jpg" width="250" height="100" ></a>
                        <h2 class="section-heading mb-4">
                        <span class="section-heading-upper">Makan Tengah Hari </span>
                        </h2></center>
                      </div>
                </tr>
                <tr>
                    <div class="container">
                        <center><a class="list-unstyled-item list-hours-item d-flex" href="snackM.php?selected={$selected}"><img border="0" src="img/dinner.jpeg" width="250" height="100" ></a><h2 class="section-heading mb-4">
                        <span class="section-heading-upper">Snack </span>
                        </h2></center>
                      </div>
                </tr>
                <tr>
                    <div class="container">
                        <center><a class="list-unstyled-item list-hours-item d-flex" href="dinnerM.php?selected={$selected}"><img border="0" src="img/snack.jpg" width="250" height="100" ></a><h2 class="section-heading mb-4">
                        <span class="section-heading-upper">Makan malam </span>
                        </h2></center>
                      </div>
                </tr>
           </tbody>
              </table>    

第三页(bfasM.php) 在这个页面上,我想根据他们在第一页和第二页中选择的内容进行显示。

0 个答案:

没有答案