有关为什么标签在第二次回声结束时不打印的任何建议?

时间:2014-03-13 21:02:08

标签: php html mysql

第二个echo语句打印时没有关闭</option>标记。但正确打印其余代码。如果我检查HTML,文本Any Publisher ...将留在''单引号中。感谢

 function getPublishers (){

    $sql = "SELECT DISTINCT publisher FROM book ORDER BY publisher ASC";
    $rs = mysql_query($sql) or die(mysql_error());
    $rows = mysql_fetch_assoc($rs);
    $tot_rows = mysql_num_rows($rs);
    if($tot_rows>0){
        echo "<select name=\"srch_publisher\" id=\"srch_publisher\>\n";
        **echo "<option value\"\">Any Publisher&hellip;*</option>*\n";**
        do{
            echo "<option value=\"".$rows['publisher']."\">".$rows['publisher']."</option>";
        } while($rows = mysql_fetch_assoc($rs));
        echo "</select>";
    }
    mysql_free_result($rs);
}

1 个答案:

答案 0 :(得分:0)

您在id="srch_publisher"之后错过了结束引号:

echo "<select name=\"srch_publisher\" id=\"srch_publisher\>\n";
                                                         ↑
                                  missing closing quote (") at this position