Reputation: 65
I want button control to display instead of anchor tag, so that I am able to set some css to that button.
here what I tried:
if ($number >= 1) {
echo "<a href='pagination2.php?page=" . ($number - 1) . "'>Prev </a>";
}
but I want to display button instead of anchor tag. How to do that?
Upvotes: 0
Views: 88
Reputation: 2000
Quick answer:
if ($number >= 1) {
echo "<button onclick=\"location.href='"pagination2.php?page=" . ($number - 1) . "'\">Prev</button>";
}
If you don't already have a template, Bootstrap has some nice breadcrumbs that might help you do what you want. Alternatively, you can add the class .btn
(also from Bootstrap) to an <a>
tag.
For a more in-depth description, you might want to take a look at this question on Stack Overflow.
Upvotes: 0
Reputation: 1527
You can write like this
if ($number >= 1) {
echo "<a href='pagination2.php?page=" . ($number - 1) . "'><button>Prev</button></a>";
}
in this you have no require to add any css
Upvotes: 0
Reputation: 870
If you want a button instead of an anchor tag, use this
if ($number >= 1) {
echo "<button onclick='window.location=pagination2.php?page=" . ($number - 1) . "'>Prev</button>";
}
Then apply the CSS as you choose.
Upvotes: 0
Reputation: 651
Give a class
to the anchor
tag. And apply CSS
a.button {
-webkit-appearance: button;
-moz-appearance: button;
appearance: button;
text-decoration: none;
color: initial;
}
if ($number >= 1) {
echo "<a href='pagination2.php?page=" . ($number - 1) . "' class="button">Prev </a>";
}
Upvotes: 0
Reputation: 794
<style>
.button {
font: bold 15px Arial;
text-decoration: none;
background-color: #EEEEEE;
color: #333344;
padding: 2px 6px 2px 6px;
border-top: 1px solid #CCCCCC;
border-right: 1px solid #333333;
border-bottom: 1px solid #333333;
border-left: 1px solid #CCCCCC;
}
</style>
if ($number >= 1) {
echo "<a class ='button' href='pagination2.php?page=" . ($number - 1) . "'>Prev </a>";
}
May this helps you. Css code need to add in style sheet file. If you want to learn bootstrap it is here Bootstarp
Upvotes: 2