0

no border shows up when setting style in the table row below, inside the while loop? why? Background color setting works fine, but not this... NO BORDER SHOWS UP...

    // Build Result String
$display_table = "<table>";
while($row = mysql_fetch_array($qry_result)){

$display_table .= "<tr style='border-top-width: thin; border-top-style: solid;'>"; //  wont work here, why?????

$display_table .= "<td width='110' rowspan='2'>BILD HÄR</td>";
$display_table .= "<td width='377' height='15'>$row[headline]</td>";
$display_table .= "<td width='67' rowspan='2'>$row[insert_date]</td>";
$display_table .= "</tr>";
$display_table .= "<tr>";
$display_table .= "<td height='15'>$row[price]:-</td>";
$display_table .= "</tr>";
}

$display_table .= "</table>";
echo $display_table;
2
  • 2
    What makes you think you can't do that? A PHP compiler error? Something wrong with the HTML output? A CSS parsing error? Something unexpected in the CSS rendering? Please be specific. Commented Oct 15, 2009 at 13:23
  • Ben - a game of "hunt the error" can sometimes be fun Commented Oct 15, 2009 at 13:25

2 Answers 2

3

You can't use the line

$display_table .= "<tr class="blablabla">"; 

Because if you look, you're closing the quotes just before blablabla, so PHP interprets that as PHP, not as a string.

If you need to use double quotes in a string, wrap the string in single quotes.

You'd so something like this in the above situation

$display_table .= '<tr class="blablabla">'; 

Have a look at PHP's strings manual page

Sign up to request clarification or add additional context in comments.

3 Comments

If you still want to use double-quotes, you can escape them like: $display_table .= "<tr class=\"blabala\">"; Or, as suggested use html single quotes. A tip, it looks like you might be better just leavin the html as html, and adding php <?= or <?php echo $row[headline]; ?> into the html. You could also consider using HEREDOCS for multi-line variables.
@CodeJoust: embedding php tags in html as you suggest it is bad coding style. It makes the code unreadable and unmaintainable.
camran changed the content of the question. Since he now asks a different question, the answer you provided is no longer relevant, hence the gone accepted answer :).
0
$display_table .= "<tr class='blablabla'>";

or

$display_table .= "<tr class=\"blablabla\">";

obvious, since your closing your string with " in the middle of the line...

2 Comments

single quotes in HTML output? I'm pretty sure the standard is to use double!
it's still possible and he uses it anyway in the other tags.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.