样式化php表单提交按钮

时间:2019-04-24 11:38:27

标签: html css forms

我正在根据某些用户输入条件从数据库中回显表单。表单将包含2个按钮。我已经成功完成了。我只是想样式化表单中的按钮(用于进一步步骤的按钮)。我不知道如何在php表单内设置按钮样式。

$result = $conn->query ($sql);

if($result ->num_rows>0){
    echo '<table >';

    while($row = $result ->fetch_assoc()){
        echo '<tr><th>Romm Number</th>';
        echo '<td >' . $row['Number']. '</td></tr>';

        echo '<tr><th>Room Temperature</th>';
        echo '<td >' . $row['TEMP']. '</td></tr>';

        //wanna style following form buttons

        echo "<form action = 'script.php' method =post>";
        echo '<tr>';
        echo "<td > "." <input type=submit    name=alarm value=Alarm> "."  </td>";
        echo "<td >"." <input type=hidden  name=view  value ='A'> "."  </td>";
        echo "</tr>";
        echo "</form>";

        echo "<form action = 'script2.php' method =post>";
        echo '<tr>';
        echo "<td >"." <input type=submit  name=control value='Log'> "." </td>";
        echo "<td >"." <input type=hidden  name=graph  value ='B'> "."  </td>";
        echo "</tr>";
        echo "</form>";
    }

    echo "</table>";

    mysqli_free_result($result);
}else {
    echo "no result";
}

//mysqli_free_result($result);
$conn->close();
}

关于在php表中设置表单按钮样式的任何建议吗?

1 个答案:

答案 0 :(得分:2)

您可以在

之类的html标签中简单地使用样式
echo "<td >"." <input type='submit' name=control value='Log' style='color:yellow;font-size:20px;border:none' class="submit"> "." </td>";

(或)

在按钮上添加特定的类并为其编写CSS,例如:

.submit {
    color: red;
}