Hiding one div and showing the other

Question

I want to run a function that will check into the database if a record exist. if it exist, div1 will show and div2 will not show. If it doesn’t exist, div2 will show and div1 will not show. How do I achieve that? please help..

            <?php
                function constituecy_div() {
            
               global $con;
               $query = "select * from accounts where Email='eickson@gmail.com'";
               $result = mysqli_query($con,$query);

               if(mysqli_fetch_assoc($result))

            {
                ?>
                <script type="text/javascript"> 
                document.getElementById('div1').style.display = 'block';
                document.getElementById('div2').style.display = 'none';
                </script>
            <?php
            }
            else 
            {
            ?>
               <script type="text/javascript"> 
                document.getElementById('div1').style.display = 'none';
                document.getElementById('div2').style.display = 'block';
                </script>
           <?php
           }
            }
            ?>
            
0
Ericson 3 months 0 Answers 8 views 0

Leave an answer