如何在php标记之间使用html5显示带有href标记的按钮



这是我用来在类似模板的面板中显示mysql数据库中的某些数据的代码。我想知道如何使用html5为每个模板显示href按钮。

while($result = mysqli_fetch_assoc($results)){
 echo '<div class="fetch">';
 echo "<p>".$result['FIRST_NAME']." ".$result['LAST_NAME']."</p>";
 echo "<p>".$result['QUALIFICATION']."</p>";
 echo "<p>".$result['Specialization']."</p>";
 echo "<p>".$result['Adress1']." ".$result['Adress2']."</p>";
 echo "<p>"."<b>Consultation Fee-</b>"." ".$result['Consultation_Fee']."  
 </p>";
 echo "<p>"."<b>Experience-</b>"." ".$result['Experience']."years"."</p>";
 echo '</div>';

您可以这样尝试:

.btn {
            background: #3498db;
            background-image: -webkit-linear-gradient(top, #3498db, #2980b9);
            background-image: -moz-linear-gradient(top, #3498db, #2980b9);
            background-image: -ms-linear-gradient(top, #3498db, #2980b9);
            background-image: -o-linear-gradient(top, #3498db, #2980b9);
            background-image: linear-gradient(to bottom, #3498db, #2980b9);
            -webkit-border-radius: 28;
            -moz-border-radius: 28;
            border-radius: 28px;
            font-family: Arial;
            color: #ffffff;
            font-size: 20px;
            padding: 10px 20px 10px 20px;
            text-decoration: none;
  }
<a href='your-link' class='btn'>Button</a>

HTML

简单的HTML方法是将它放在<form>中,在action属性中指定所需的目标URL。

<form action="http://google.com">
    <input type="submit" value="Go to Google">
</form>

如有必要,在表单上设置CSS display: inline;,使其与周围的文本保持一致。

CSS

如果允许CSS,只需使用<a>,您可以使用[appearance][1]属性([目前(2015年7月)仅Internet Explorer支持率仍然很低][2])将其样式设置为按钮。

a.button {
  -webkit-appearance: button;
  -moz-appearance: button;
  appearance: button;
  text-decoration: none;
  color: initial;
}
<a href="http://google.com" class="button">Go to Google</a>

或者从众多CSS库中选择一个,比如[Bootstrap][3]。

JavaScript

如果允许使用JavaScript,请设置window.location.href

<input type="button" onclick="location.href='http://google.com';" value="Go to Google" />

最新更新