0

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?

Mangesh Kolape
  • 65
  • 1
  • 10

5 Answers5

2
<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

Denis Bhojvani
  • 817
  • 1
  • 9
  • 18
0

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>";
}
Chaitali
  • 631
  • 4
  • 12
0

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.

Chindraba
  • 820
  • 1
  • 18
  • 19
0

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

ImBhavin95
  • 1,494
  • 2
  • 16
  • 29
0

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.

Community
  • 1
  • 1
Ashton Wiersdorf
  • 1,865
  • 12
  • 33