skip to Main Content

UPDATE …..

I hope any one can solve this problem

when I use <td> tag to show my data inside Modal popup the table is shown scatters …

while when use <h5> tag every thing is OK

here is my modal code

<div id="myModal<?php echo $row['id'];
            $x = $row['id'];
            ?>" class="modal fade" role="dialog">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                     <button type="button" class="close" data-dismiss="modal">&times;</button>
                </div>
                <div class="modal-body">
                <?php 
                  $records = mysqli_query($conn,"select * from trans where id =  $x ");  
                  while($row = mysqli_fetch_array($records))
                    {
                    ?>                      
                    <!--
                         <td> <?php echo $row['id']; ?></td>
                         <td> <?php echo $row['date']; ?></td>
                         <td> <?php echo $row['invNO']; ?></td>
                         <td> <?php echo $row['income']; ?></td> 
                    --> 
                    
                     <h6>ID : <?php echo $row['id']; ?></h6>
                     <h6>Date : <?php echo $row['date']; ?></h6>
                     <h6>inv No : <?php echo $row['invNO']; ?></h6>
                     <h6>income : <?php echo $row['income']; ?></h6>
                <?php
                    }
                ?>
                </div>
            </div>
        </div>
    </div>

2

Answers


  1. Chosen as BEST ANSWER

    I found a solution for this issue

    <div class="table1">
      <div class="table-row">
        <div class="table-col"><?php echo $row['date'];?></div>
        <div class="table-col"><?php echo $row['invNO'] ; ?></div>
        <div class="table-col"><?php echo $row['amount']; ?></div>
      </div>
    </div>
                                
    

    <style>
    .table1 {
      display: table;
      width: auto;
      border: 1px solid black;
    }
    
    .table-row {
      display: table-row;
      width: auto;
      clear: both;
    }
    
    .table-col {
      float: left;
      display: table-column;
      width: 150px;
      border: 1px solid black;
    }
    </style>


  2. From MDN, it states that:

    The <td> may only be used within a <tr> element.

    What you’re experiencing is likely a browser quirk, where it rearranges your HTML output, and puts your <td> elements in a place that you don’t expect.

    To solve this, you should either replace <td> elements with something else (like you have done with the heading tags), or remember to wrap the cells within a <table /> and <tr /> tag.

    <div class="modal-body">
     <table>
      <?php
       // ...
       while($row = mysqli_fetch_array($records))
        {
        ?>
        <tr>
         <td>
          ...
        </tr>
      <?php
       }
      ?>
     </table>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search