Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9044989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:07:59+00:00 2026-06-16T11:07:59+00:00

This is my first post on some Q&A site. Point out my tiniest mistakes

  • 0

This is my first post on some Q&A site. Point out my tiniest mistakes and correct me. I’ve started learning PHP and I am using WAMP server. I am having multiple rendering issues. I will present one first. I have an index.php page on which I want to display five tables namely Branch, Student, Subject, Exam and Marks. Now I have kept display buttons for each tables mentioned above on the same page. I don’t want the page to get refreshed so the input type for the button is “button” not “submit”. And then I want to check if the button is clicked or not so I am using isset($_POST[‘button’]) where button is the name of display button for respective table. And if the button is clicked then I am displaying the datatable for that particular table only while other tables are hidden.

Rendering issue of one table at a time : I want that when I click on Display Branch Table button the Branch table will be displayed and after that if I click on Display Student Table button then Student table should be displayed and the rest of tables should be hidden and likewise for all the tables. Now the below code has the jquery which is too much redundant and I want to optimize it. Also I’ve a part of my PHP code which displays branch table whose div tag id is branch1 and for student it is student1 and likewise. On clicking the display branch button I cannot see anything happening. It means the if(isset($_POST[‘display_branch’])) is not working on button click. Also there is a div tag for each table and has different id but same class(i.e. render)
I would like to know where I am wrong here and I don’t want the page to be reloaded again.

jQuery:

$('.render').hide();
$('#display_branch').click(function (event) {
    $('#student1').hide();
    $('#subject1').hide();
    $('#exam1').hide();
    $('#marks1').hide();
    $('#branch1').show();
});

$('#display_student').click(function (event) {
    $('#subject1').hide();
    $('#exam1').hide();
    $('#marks1').hide();
    $('#branch1').hide();
    $('#student1').show();
});
$('#display_subject').click(function (event) {
    $('#subject1').show();
    $('#exam1').hide();
    $('#marks1').hide();
    $('#branch1').hide();
    $('#student1').hide();
});
$('#display_exam').click(function (event) {
    $('#subject1').hide();
    $('#exam1').show();
    $('#marks1').hide();
    $('#branch1').hide();
    $('#student1').hide();
});
$('#display_marks').click(function (event) {
    $('#subject1').hide();
    $('#exam1').hide();
    $('#marks1').show();
    $('#branch1').hide();
    $('#student1').hide();
});

Display buttons:

       <div id="display" style="position:absolute; top:100px;">
       <form action="" method="post">
       <input type="button" id="display_branch" name="display_branch" value="Display Branch Table" >
       <input type="button" id="display_student" name="display_student" value="Display Student Table">
       <input type="button" id="display_subject" name="display_subject" value="Display Subject Table">
       <input type="button" id="display_exam" name="display_exam" value="Display Exam Table">
       <input type="button" id="display_marks" name="display_marks" value="Display Marks Table">
       </form>
       </div>

PHP Code Fragment:

   if(isset($_POST['display_branch']))
   {
   $result = mysql_query("SELECT * FROM branch");?>
 <div class="render" id="branch1" style="position:absolute; left:200px; top:150px;">
        <table id="datatables" class="display">
            <thead>
                <tr>
                    <th>Branch ID</th>
                    <th>Branch Name</th>
                </tr>
            </thead>
            <tbody>
                <?php
                while ($row = mysql_fetch_array($result)) {
                $branch_id= $row['branch_id'];
                $branch_name = $row['branch_name'];?>
                    <tr>
                        <td><?php echo $branch_id;?></td>
                        <td><?php echo $branch_name;?></td>                         
                    </tr>
                    <?php
                }
                ?>
            </tbody>
        </table>
    </div>}

I searched a lot and tried many ways but not getting it perfectly. Hope this discussion will help some others to solve similar issues.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T11:08:01+00:00Added an answer on June 16, 2026 at 11:08 am
    $_POST['display_branch']
    

    This requires POST request with display_branch param given.

    You got basically two options to hide/show elements like this.

    • 1 have them all hidden at the load time and then just selectively show like this http://jsfiddle.net/DVd3A/1/
    • 2 do an ajax request on button click with $.ajax() like this http://jsfiddle.net/sLXMU/3/
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first major WordPress site from absolute scratch. My PHP skills are
I am going through some very basic AJAX programming in Learning PHP, MySQL &
So I have a simple site that is using php to do some simple
need some enlightment here, and this is my first post here. I would like
This is my first post, I'm new to this site, but I've been lurking
This is my first post here so kindly pardon any mistakes that I have.
This is my first post in this forum, so please, be patient with me.
This is my first post and I my first experience with jquery. I have
This is my first post on stackoverflow, so please excuse me if my question
This is my first post, thx, you've been very helpful. But I'm stuck. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.