How do I apply CSS to the table generated into another window?


Tags: php,javascript,html,css

Problem :

I am unsure where to apply my CSS to the table I have generated. I am getting

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/content/08/10674308/html/venuesearch.php on line 133

My line 133 is this

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

Here is the code I am working with

<?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

External 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;
}


Solution :

Your line has indeed an error, change this:

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

to this:

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

The problem was with the way you concatenated table-2, because you used the . concatenation operator, and then didn't use it to concatenate it with the rest of the string. Also, you just wanted to concatenate table-2 as a stringe (as this is the id defined in your CSS) and not as a variable (which would be $table-2 anyways).

So that caused a bunch of mistakes.

Also, not sure why you did all that escaping, while you needed just one backslash or just using the single quotes inside your double quotes.


    CSS Howto..

    How to Limit the Div Exactly into the Screen Size

    How to apply SVG so that it works in IE background image

    how to replicate pinterest.com's absolute div stacking layout [closed]

    How to modify css class of container for specific element ID

    How to resize image on window resize in CSS?

    How to apply only one css file out of two css files included?

    How to Create CSS Selector Element including index

    How know CSS version - ASP.NET - VS Community 2013

    How do we change the color and size of dingbat unicode characters in mobile Safari? (html entities)

    How to make controlls for epub using HTML 5,JavaScript and CSS?

    How to fit textarea exactly inside a div - CSS

    How do I make a hamburger menu display on the right side?

    python how to parse css file as key value [closed]

    How do I make the Brand, links, and facebook link on the same line? Bootstrap 3

    TW Bootstrap: How to overflow columns

    How to have the class=“selected” depending on what the current page/url is

    how to force page break between absolutely positioned elements in css

    LESS - confusion about how mixins take parameters

    How to revert back to Desktop website from Mobile Website when using CSS Media Queries?

    Bootstrap progress bar with gradient color showing proportionally on active width

    How does google elegantizr work?

    How to add external CSS to HTML 'style'

    Show an image from b&w to color as if it were loading (left to right)

    How to force two elements become hovered at the same time?

    How to keep navigation tab remain unchanged

    How to position boxes like a posterboard with CSS?

    How to apply CSS rotate transition around glyph's vertical middle or centerpoint

    How can I center a div

    How to make a hidden border side inherit border properties in CSS

    How to read different CSS classes with the same beginning with jquery?