0

I am making this website in PHP, which shows some data from the DataBase.... A website that shows results of the students.

Now I am retrieving some data from the DataBase and displaying it in the table. I have 2 Buttons. Both just redirect. One is above the table, another one is below the table. Now whatever I write below the table, is shown above the table.

<div class='instructionContainer'>
    Click on any of the record to redirect yourself to the image. You can also download the images as PDF or PNG.
</div>
<div class="rankerButtonContainer"><button class='rankerButton' onclick=setTimeout(function(){window.location="ranker.php?sem=<?php echo $_GET['sem']; ?>"},500);>Rankers</button></div>

<table border='0' align='center'>
    <tr class='tableHeading'>
        <th class="number">Sr No.
        <th>Name
        <th>Seat No.
        <th>Marks
        <th colspan='2'>Download
    </tr>

<?php
    $result=$conObj->query("select * from data");
    $i=1;
    if($_GET["sem"]==1)
        echo "<div class='noData'>Data is not yet entered...</div>";
    elseif($_GET["sem"]==2)
        echo "<h1>Data is not yet entered...</h1>";
    elseif($_GET["sem"]==3)
        echo "<h1>Data is not yet entered...</h1>";
    elseif($_GET["sem"]==4)
        echo "<h1>Data is not yet entered...</h1>";
    elseif($_GET["sem"]==5){
        while($temp=mysqli_fetch_array($result)){
            if($temp[16]==  531335)
                continue;
            ?>
                <tr id='<?php if($temp[18]) echo "pass"; else echo "fail"; ?>' onclick="window.location='assets/BCA5/<?php echo $temp[16]; ?>.png'">
                    <td class="number"><?php echo $i; ?>
                    <td><?php echo $temp[2]." ".$temp[3]; ?>
                    <td><?php echo $temp[16]; ?>
                    <td><?php echo $temp[17]; ?>
                    <td id='imgTd'><a href='assets/BCA5/<?php echo $temp[16]; ?>.pdf' download><img src='assets/images/icons/pdf.png'/></a>
                    <td id='imgTd'><a href='assets/BCA5/<?php echo $temp[16]; ?>.png' download><img src='assets/images/icons/camera.png'/></a>

                </tr>
            <?php
            $i+=1;
        }
    }
    elseif($_GET["sem"]==6)
        echo "<h1>Data is not yet entered..</h1>";
?>

<div class="backButtonContainer"><button class='backButton' onclick=setTimeout(function(){window.location="home.php"},500);>Rankers</button></div>

The .backButtonContainer and it's contents are shown above the table, which I don't want it to. So can anyone tell me the solution to this and also the reason for it to happen like this. And I don't want any alternate solutions, I just want my button to be exactly below the table, similar to how .rankerButtonContainer is above the table.

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
AZZlOl
  • 17
  • 1
  • 5

4 Answers4

3

You forget adding </table> after while loop block ended.

Bassem Samir
  • 114
  • 9
1

Hello Dear as you wanted

" I just want my button to be exactly below the table, similar to how .rankerButtonContainer is above the table. "

on the based on your question i show you forget to add table end-tag </table> . before .backButtonContainer Please add this then hopefully it will run correctly.

0

This has little to do with PHP. You're placing html inside the <table>, but not in a <td>. All content placed like that will be placed above the table as it doesn't know what to do with it.

Martijn
  • 15,791
  • 4
  • 36
  • 68
  • 1
    I'm sorry. I didn't notice it. And It works. Thank You for helping me out and explaining it.... Good Explanation.....! – AZZlOl Oct 27 '19 at 20:38
0

As far as I know you can't use other html elements in a table accept the tr, td, th, thead, tbody etc.. If I'm right you can use any html tag within the td and th tag.

Before you show the <h1> tag add </table> close before the h1 tag or div and the content will show below your table

Also like Bassem Samir said add close table after you're while loop. Hope this will help you a bit.

Baracuda078
  • 677
  • 1
  • 5
  • 10
  • I'm sorry. I didn't notice it. And It works. Thank You for helping me out and listing explaining it.... Thank you for the extra information... – AZZlOl Oct 27 '19 at 20:37