How to display some text from sql when the checkbox is checked (php)

Viewed 20

Picture of site

I want to check the checkbox of the area and show only the area. Not population and others (click the link to see the picture)

try one


  <?php
                    if (isset($_POST['dziritadi'])) {
                        echo "checked fartobi" . "<br>";
                    }
                    if (isset($_POST['test2'])) {
                        echo "checked value2";
                    }
                    ?>

try two


    <?php
                            if (isset($_POST['submit'])) {
    
                                if (!empty($_POST['dziritadi'])) {
    
                                    foreach ($_POST['dziritadi'] as $value) {
                                        echo "value : " . $value . '<br/>';
                                    }
                                }
                            }
                        ?>

also not working.

see my code: list.php


    <form method="POST" action="">
    
                <table class="table table-bordered bg-black">
                    <tbody>
                        <td class="td-empty"> <br>ძირითადი მაჩვენებლები</td>
                        <?php
                        require 'connection.php';
                        $query = mysqli_query($link, "SELECT * FROM `regions`");
                        while ($fetch = mysqli_fetch_array($query)) {
                        ?>
                            <tr class="grid">
                                <td><input type="checkbox" name="reg_id[]" value="<?php echo $fetch['ID'] ?>" /><?php echo $fetch['Name'] ?></td>
                            </tr>
                            <script>
    
                            </script>
                        <?php
                        }
                        ?>
                    </tbody>
                    <tbody class="col-sm d-flex">
                        <tr class="grid">
    
                            <!-- მცდელობა1 რათა გავასწორო ძირითადის ჩეკბოქსი -->
    
                            <!-- <?php
                            if (isset($_POST['dziritadi'])) {
                                echo "checked fartobi" . "<br>";
                            }
                            if (isset($_POST['test2'])) {
                                echo "checked value2";
                            }
                            ?> -->
                            
                            <th>ფართობი (კვ.კმ) <input class="right" id="press" type="checkbox" name="dziritadi" value="fartobi" onclick="myFunction()" /></th>
                            <th>მოსახლეობის რიცხოვნობა (ათასი) <input class="right" id="press" type="checkbox" name="dziritadi" onclick="myFunction()" /></th>
                            <th>მთლიანი შიდა პროდუქტი (მლნ. ლარი) <input class="right" id="press" type="checkbox" name="dziritadi" onclick="myFunction()" /></th>
                            <th>მთლიანი შიდა პროდუქტი ერთ სულ მოსახლეზე (აშშ დოლარი) <input class="right" id="press" type="checkbox" name="dziritadi" onclick="myFunction()" /></th>
                            <th>უმუშევრობის დონე (%) <input class="right" id="press" type="checkbox" name="dziritadi" onclick="myFunction()" /></th>
                            <th>დასაქმებულთა რაოდენობა, სულ (ათასი კაცი) <input class="right" id="press" type="checkbox" name="dziritadi" onclick="myFunction()" /></th>
                            <th>დასაქმებულთა რაოდენობა - ბიზნეს სექტორში (ათასი კაცი) <input class="right" id="press" type="checkbox" name="dziritadi" onclick="myFunction()" /></th>
                            <th>დასაქმებულთა საშუალოთვიური ხელფასი - ბიზნეს სექტორში (ლარი) <input class="right" id="press" type="checkbox" name="dziritadi" onclick="myFunction()" /></th>
                            <th>რეგისტრირებული ეკონომიკური სუბიექტების რაოდენობა (ერთეული) <input class="right" id="press" type="checkbox" name="dziritadi" onclick="myFunction()" /></th>
                        </tr>
    
                        <!-- მცდელობა2 რათა გავასწორო ძირითადის ჩეკბოქსი -->
                        <?php
                            if (isset($_POST['submit'])) {
    
                                if (!empty($_POST['dziritadi'])) {
    
                                    foreach ($_POST['dziritadi'] as $value) {
                                        echo "value : " . $value . '<br/>';
                                    }
                                }
                            }
                        ?>
                        <div class="inline d-flex ">
                            <?php include 'get_select.php' ?>
                        </div>
                    </tbody>
                </table>
    
                <center class="position-center"><button name="get" class="btn">ძიება</button></center>
            </form>

get_select.php

    <?php
    require 'connection.php';
    if (isset($_POST['get'])) {
        if (!empty($_POST['reg_id'])) {
    
            $query = mysqli_query($link, "SELECT * FROM `regions` WHERE `ID` IN (" . implode(',', $_POST['reg_id']) . ")") or die(mysqli_error());
            echo "";
            while ($fetch = mysqli_fetch_array($query)) {
                echo "
                    <tr>
                            <td>" . $fetch['Area'] . "</td>
                            <td>" . $fetch['Population'] . "</td>
                            <td>" . $fetch['GDP'] . "</td>
                            <td>" . $fetch['GDPPerCapita'] . "</td>
                            <td>" . $fetch['UnemploymentRate'] . "</td>
                            <td>" . $fetch['EmploymentRate'] . "</td>
                            <td>" . $fetch['EmploymentRateIndustry'] . "</td>
                            <td>" . $fetch['AverageSalaryIndustry'] . "</td>
                            <td>" . $fetch['RegistredEntities'] . "</td>
                            </tr>
                        ";
            }
            echo "";
        }
    }

pls, help me.

It looks like your post is mostly code; please add some more details. It looks like your post is mostly code; please add some more details. It looks like your post is mostly code; please add some more details. It looks like your post is mostly code; please add some more details. It looks like your post is mostly code; please add some more details. It looks like your post is mostly code; please add some more details.

0 Answers
Related