how to print <td> tags in php

Asked

Viewed 85 times

0

I did it two ways:

wanted to tag <td> in abreTD and </td> in the close when I printit on the page, the problem is if I just 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 by creating a textarea and having it printed in, then it works, the problem is that it doesn’t have the line breaking, how do I print inside the textarea with line break? I tried to do

echo nl2br('$html .= ' . '\'<td>\''. ' . ' . '$'. $coluna . ' . ' . '\'</td>\''. ';'); but it didn’t 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>";

2 answers

0

Why do you have an echo '$html'?

From what I understand you are trying 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;
  • echo $table;? where this variable came from?

  • actually I’m just pulling the data from the database, mounting the data and playing the tags tds, then I just copy and paste (the table is already created with their respective trs)

  • I used the wrong variable. I’ve fixed it. Regardless of the source, the procedure is the same.

0


I don’t know if I understand what you want, but do you want when you print a screen or print the page to appear the "td" tag on the page ? If that’s what you can do in two ways:

Escape the HTML entity Substitute < for &lt; and > for &gt;

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.