tags:

views:

30

answers:

2

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;
A: 
$display_table .= "<tr class='blablabla'>";

or

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

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

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

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

Mez
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
@CodeJoust: embedding php tags in html as you suggest it is bad coding style. It makes the code unreadable and unmaintainable.
stefita
*wonders where the accepted answer went*
Mez
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 :).
stefita