0

我不确定在哪里将我的 CSS 应用到我生成的表中。我正进入(状态

解析错误:语法错误,第 133 行 /home/content/08/10674308/html/venuesearch.php 中的意外 T_CONSTANT_ENCAPSED_STRING

我的第 133 行是这个

$resultString .= "<div id=".table-2" class=\\\"results\\\">There are " .  $result->num_rows . " results for $city, $state:<br /><br /><table>";

这是我正在使用的代码

<?php

    include "dbc.php"; 

    $query = <<<EOF
SELECT * FROM
    venueprofile 
WHERE 
    city= '$city' 
    AND 
    st= '$state'
    AND
    capacity 
    BETWEEN 
        $capacity1 
        AND 
        $capacity2; 
EOF;

if ($result = mysqli_query($dbc, $query)){
    $resultString = "<html>";
    $resultString .= "<head><link href=\\\"default.css\\\" rel=\\\"stylesheet\\\"       `enter code here`type=\\\"text/css\\\" media=\\\"all\\\" /></head><body>";  

    $resultString .= "<div id=".table-2" class=\\\"results\\\">There are " . $result-`enter code here`>num_rows . " results for $city, $state:<br /><br /><table>";

    $resultString .= "  <tr><thead><th></th>";
    $resultString .= "      <th>Venue Name</th>";
    $resultString .= "      <th>Capacity</th>";
    $resultString .= "      <th>City</th>";
    $resultString .= "      <th>State</th>";
    $resultString .= "      <th>Telephone</th>";
    $resultString .= "      <th>Contact</th>";
    $resultString .= "      <th>Email</th>";    
    $resultString .= "  </thead></tr>";
    $rowCount = 0;
    while ($row =mysqli_fetch_assoc($result))
    {
        $rowCount++;
        $resultString .= "<tbody><tr>";
        $resultString .= "<td>$rowCount</td>";
        $resultString .= "<td>" . $row['VenueName'] . "</td>";
        $resultString .= "<td>" . $row['capacity'] . "</td>";
        $resultString .= "<td>" . $row['city'] . "</td>";
        $resultString .= "<td>" . $row['st'] . "</td>";
        $resultString .= "<td>" . $row['tele'] . "</td>";
        $resultString .= "<td>" . $row['contact'] . "</td>";
        $resultString .= "<td>" . $row['EmailAddress'] . "</td>";       
        $resultString .= "</tr></tbody>";
    }
    $resultString .= "</table></div></body></html>";
?>
<script type="text/javascript">
    newWindow("resultsWindow"+(resultsWindows.length - 1),"<?php echo $resultString; ?`enter code here`>",400,400);
</script>
<?php

外部 CSS

#table-2 {
    border: 1px solid #e3e3e3;
    background-color: #f2f2f2;
        width: 100%;
    border-radius: 6px;
    -webkit-border-radius: 6px;
    -moz-border-radius: 6px;
}
#table-2 td, #table-2 th {
    padding: 5px;
    color: #333;
}


#table-2 thead {
    font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
    padding: .2em 0 .2em .5em;
    text-align: left;
    color: #4B4B4B;
    background-color: #C8C8C8;
    background-image: -webkit-gradient(linear, left top, left bottom, from(#f2f2f2), to(#e3e3e3), color-stop(.6,#B3B3B3));
    background-image: -moz-linear-gradient(top, #D6D6D6, #B0B0B0, #B3B3B3 90%);
    border-bottom: solid 1px #999;
}
#table-2 th {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 17px;
    line-height: 20px;
    font-style: normal;
    font-weight: normal;
    text-align: left;
    text-shadow: white 1px 1px 1px;
}
#table-2 td {
    line-height: 20px;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 14px;
    border-bottom: 1px solid #fff;
    border-top: 1px solid #fff;
}
#table-2 td:hover {
    background-color: #fff;
}
4

1 回答 1

1

您的行确实有错误,请更改此:

$resultString .= "<div id=".table-2" class=\\\"results\\\">There are " .  $result->num_rows . " results for $city, $state:<br /><br /><table>";

对此:

$resultString .= "<div id='table-2' class='results'>There are " .  $result->num_rows . " results for $city, $state:<br /><br /><table>";

问题在于您连接的方式table-2,因为您使用了.连接运算符,然后没有使用它将它与字符串的其余部分连接起来。此外,您只想连接table-2为字符串(因为这是id在您的 CSS 中定义的),而不是作为变量($table-2无论如何都是)。

所以导致了一堆错误。

此外,不知道为什么你做了所有的转义,而你只需要一个backslash或只是在你的双引号中使用单引号。

于 2013-05-17T21:23:51.787 回答