This is my line of code in php which shows the page numbers, which are automatically generated based on the content in the table. Since all the page numbers have the same color I want to display the current active page, I wanted to do it with a condition in the class but due to the anchor tag already being in the ""
of echo, and the class starting with '
, once i put the '
for condition, the class is ended sooner and the condition is not made.
Is there a way to bypass this or use something else for inside of the ' '
?
Or is there another way to show the current active link?
echo "<a class='{% if page.url. =='?page=$x' %}active{% endif %}' href='?page=$x'> $x </a>";
And if anyone needs some more code, this is the whole php code for printing all the pages based on the number of items in the table
for($x = 1; $x <= $totalPages + 1; $x++){
?>
<div class='page'>
<?php
echo "<a class='{% if page.url. =='?page=$x' %}{% endif %}' href='?page=$x'> $x </a>";
?>
</div>
<?php
}