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?

1
  • I think you can do that with help of css. And if you are using bootstrap then there is default class btn is present. Commented Feb 25, 2017 at 4:53

5 Answers 5

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

Sign up to request clarification or add additional context in comments.

Comments

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>";
}

Comments

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.

Comments

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

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.