PHP文件中的CSS表单边框格式

时间:2014-11-20 20:37:10

标签: php html css forms

我试图将一些CSS嵌入到我的PHP文件中。如何正确添加我的CSS,以便每个被调用的表单将在黑色边框内呈现?这是我到目前为止所尝试的。

 while ($ratings = mysql_fetch_array($q))
    {
        //This outputs the doctors's name
        echo "Doctor's name:" . $ratings['doctor_name'] ."<br />";

            // Retrieve the id of the doctor which was posted on
            $id = $_POST['id'];

            echo "<style> form { border-style: solid; border-color: #ffffff}"; 

            //This outputs a textarea for the user to submit comments

            echo "<b>Your Experience: </b>";
            echo "<form method='post' action='review_doctors.php'> 

                    <textarea name='body'></textarea>
                    <input type='submit' name='submit' value='Send'/>

                    <input type='hidden' name='id' value='$ratings[id]' />

                    </style>

                 </form>
                 ";


            echo "<br />";
}

1 个答案:

答案 0 :(得分:2)

如评论中所述:“样式标记应仅包含样式”。

?>
<style>
form {
    border: 3px solid black;
}
</style>
<?php
while ($ratings = mysql_fetch_array($q)) {
    echo "<form>...</form>"
}

如果您想重复使用样式,可以将它们放在自己的文件中,然后将它们包含在每个页面中:

?>
<link rel="stylesheet" type="text/css" href="/path/to/mystyle.css">
<?php
// ...