Search code examples
phphtmldatatable

pagination in html page


I am showing all my products in rows, but the code which I am using shows the result in columns. I am using the datatable pagination, I don't know how I am using pagination in my web site please help me. enter image description here

<table  id="datatables" class="table no-margin">
    <thead >
         <tr>
             <th></th>
         </tr>
    </thead>
    <tbody class="df">
        <?php 
            $pr = mysqli_query($link,"select * from product where company_id = '".$company_id."'");
            while($prd = mysqli_fetch_array($pr))
            {
                $price = mysqli_fetch_array(mysqli_query($link,"select * from 
                admin_price where p_code = '".$prd['p_code']."'"));
            ?>  
        <tr>            
    <td>
        <?php echo("<a href='single.php?
            p_code=".$prd['p_code']."'>"); ?>
        <div class="part-secz">                  
            <img src="<?php echo("images/".$prd['image']); ?>" alt=""/>
            <div class="part-infoz">
                <?php 
                    echo("<a class='asd' href='single.php?p_code=".$prd['p_code']."'>"); 
                ?>
                <h5>
                    <?php echo($prd['p_code']); ?><span>$ <?php echo($price['price']); ?>
                    </span>
                </h5>
                <?php 
                    echo("</a>");?>
                    <?php echo("<a class='add-cart' href='single.php p_code=".$prd['p_code']."'>"); ?> Quick View<?php 
                    echo("</a>");?>
                    <?php echo("<a class='qck' href='single.php p_code=".$prd['p_code']."'>"); ?>BUY NOW</a><?php 
                    echo("</a>");?>
                </div>
            </div>   
        </td>
        <div class="clearfix">
        </div>
    </tr>                           
    <?php
        }
    ?>

Solution

  • Just get your tag outside of while loop

    <tr>
     while($prd = mysqli_fetch_array($pr))
       {
    
    <td> Your Values </td>
    
    }
    </tr>