how to print td tags in php

0

I did it in two ways:

I wanted to put the tag <td> in the openTD and </td> in the DT date when I printed on the page, the problem is if I simply put the tags, they disappear.

while ($campo = mysql_fetch_assoc($query)) {
    $coluna = $campo["Field"];
     echo '$html .= ' . '\'abreTD\''. ' . ' . '$'.  $coluna . ' . ' . '\'fechaTD\''. ';';
     echo "<br>";
}

The only way I found to print is to create a textarea and to print it in, that's where it works, the problem is that it does not have the line break , as I do in the textarea com line break? I tried to do

echo nl2br('$html .= ' . '\'<td>\''. ' . ' . '$'. $coluna . ' . ' . '\'</td>\''. ';'); but it did not work out.

echo "<textarea class='textoarea' style='width: 100%; height: 60%;'>";
while ($result = mysql_fetch_assoc($query)) {
    $coluna = $result["Field"];
    echo '$html .= ' . '\'<td>\''. ' . ' . '$'.  $coluna . ' . ' . '\'</td>\''. ';';
}
echo "</textarea>";
    
asked by anonymous 28.05.2015 / 16:27

2 answers

0

I do not know if I understand what you want, but do you want it when you make a print screen or print the page the "td" tag appears on the page? If so, you can do it in two ways:

Escaping the HTML entity Replace < with &lt; and > with &gt;

Use code display HTML tags Use the <code>Seu código HTML aqui que não será renderizado pelo navegador</code> tag

    
28.05.2015 / 16:36
0

Why has an echo '$ html'?

So I understand you're wanting to concatenate some content in the $ html variable, which should already have something. So, the correct one would be:

$html = 'conteudo inicial';
$html.= '<table><tr><td>conteudo da table</td></tr></table>';
echo $html;
    
28.05.2015 / 16:31