I'm looking to display a text field being called from a database. Every other row is small bit of information, but I'm calling a text field with a few lines. It looks like this:

echo "<tr>";
          echo "<td>10k</td>";
          echo "<td></td>";
          echo "<td>" . $list['tenk'] . "</td>";
          echo "<td>" . $list['tenkl'] . "</td>";
          echo "<td>" . $list['tenkd'] . "</td>";
          echo "<td>" . $list['tenc'] . "</td>";

         echo "</tr>";

that's an example. But the last field ('tenc') is a comment field and needs to be bigger than the other fields. I'm sure this is quite basic but I'm a newbie.

thanks!

Dani AI

Generated

As found, widening the table column with CSS is the fastest fix. For more control and better UX there are a few reliable options depending on whether you want the comment to wrap, preserve line breaks, scroll, or span the whole row.

A compact, robust approach is to give the comment cell a class and let CSS handle wrapping and preserved newlines:

td.comment {
  max-width: 360px;            /* visual limit */
  white-space: pre-wrap;       /* preserve newlines, but still wrap long lines */
  overflow-wrap: break-word;   /* break long words to avoid layout break */
  vertical-align: top;
}

If you need column widths to be respected, set table-layout: fixed or define widths with a colgroup (see MDN on table-layout). To preserve user-entered newlines from the database without injecting HTML, output the text safely from PHP, for example:

echo '<td class="comment">' . nl2br(htmlspecialchars($comment, ENT_QUOTES)) . '</td>';

Alternatives: give the comment cell a fixed height with overflow:auto to show a scroll for very long notes, or use colspan to let the comment occupy the entire table width when a single, full-width comment looks better. For word-breaking behavior and whitespace handling, see MDN docs on overflow-wrap and white-space.

Cautions: always escape database text before output to avoid XSS, and test how the layout behaves on small screens; wrapping or full-width rows usually give the best mobile results.

sorry for the stupid question.

i just widened the column with basic css

sorry

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.