0
<div class="row">
    <div class="container">
        <div class="col s12">
            <ul class="pagination center-align text-blue">

            <?php 

                $get_pagCount = "SELECT COUNT(p_id) as count_pro FROM products";

                $run_pagCount = mysqli_query($con,$get_pagCount);

                $row_pagCount = mysqli_fetch_array($run_pagCount);

                $totalRecords = $row_pagCount["count_pro"];

                $totalPages = ceil($totalRecords / $perPage);               

            ?>  

            <!-- left symbol of pagination -->          

            <?php if ($paginationNo==1): ?>

                <li class="waves-effect disabled"><a href="#!"><i class="material-icons">chevron_left</i></a></li>

            <?php endif; ?>

            <?php if ($paginationNo!==1): ?>

                <li class="waves-effect"><a href="products.php?paginationId=<?php echo($paginationNo-1); ?>"><i class="material-icons">chevron_left</i></a></li>

            <?php endif; ?>


            <!-- pagination numbers dynamics -->

            <?php for ($i=1; $i<=$totalPages; $i++): ?>

                <?php if ($paginationNo == $i): ?>

                    <li class="waves-effect active"><a href="#!"><?php echo($i); ?></a></li>

                <?php endif; ?>

                <?php if ($paginationNo !== $i): ?>

                    <li class="waves-effect"><a href="products.php?paginationId=<?php echo($i); ?>">2</a></li>

                <?php endif; ?>

            <?php endfor; ?>




            <!-- right symbol of pagination -->

            <?php if ($paginationNo == $totalPages): ?>

                <li class="waves-effect disabled"><a href="#!"><i class="material-icons">chevron_right</i></a></li>

            <?php endif; ?>

            <?php if ($paginationNo !== $totalPages): ?>

                <li class="waves-effect"><a href="products.php?paginationId=<?php echo($paginationNo+1); ?>"><i class="material-icons">chevron_right</i></a></li>


            <?php endif; ?>

            </ul>
        </div>
    </div>
</div>

all the if conditions of equal to and not equal in the above code both returns true for the same condition. how is that possible? like in the image below there are two arrows created for the left arrow of pagination and two li for 1 pagination one active and other for not active as stated in if conditions in the code above. and if i make the $paginationNo = 5 like equal to $totalPages then the left arrow is created one time but the right arrow of pagination gets created two times output of the code above

  • 2
    Try just `!=` as I assume `$paginationNo` is probably a string and `1` is numeric therefore the test fails on data type – RiggsFolly Mar 24 '20 at 15:50
  • hahahaha its so obvious. I should probably go get some sleep. thank you so much it was driving me nuts. – Muhammad Kashif Mar 24 '20 at 15:53
  • 1
    Does this answer your question? [How do the PHP equality (== double equals) and identity (=== triple equals) comparison operators differ?](https://stackoverflow.com/questions/80646/how-do-the-php-equality-double-equals-and-identity-triple-equals-comp) – Patrick Q Mar 24 '20 at 15:56

1 Answers1

0

"Try just != as I assume $paginationNo is probably a string and 1 is numeric therefore the test fails on data type" <--- this worked