Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make my output text scrollable using PHP?

The text that I am trying to echo from $data is way too long and it is going off the screen beyond the boundaries of the table. In addition to that all the text is getting displayed without line breaks (or blank lines) or proper spacing.

My simple PHP code:

<div id="sampleid1" class="tabcontent" style="margin-left:48px;">
    <table width="510" border="0" cellspacing="4" cellpadding="4" class="SampleClass">
        <tr>
            <td>
                <?php echo Sample1_LABEL;?>
            </td>
            <th align="left"><strong>:</strong>
            </th>
            <td>
                <?php echo $data[ 'Sample1'];?>
            </td>
        </tr>
        <tr>
            <td>
                <?php echo Sample2_LABEL;?>
            </td>
            <th align="left"><strong>:</strong>
            </th>
            <td>
                <?php echo $data[ 'Sample2'];?>
            </td>
        </tr>
    </table>
</div>

In Summary:

  1. I need the text that I am retrieving using the $data to get formatted in such a way that the line breaks are displayed in the output upon echoing.
  2. I need that output text to be scrollable so no text will go off the screen beyond the boundaries.
like image 561
CompilingCyborg Avatar asked Mar 07 '26 06:03

CompilingCyborg


1 Answers

you need to set CSS to the TD tag where you echo that $data...

<td style="height:150px; overflow-y:scroll;">

My mistake.. TD dont accept overflow so you may do this::

<td style="height:150px"><div style="height:100%; overflow-y:scroll;">..PHPCODE...</div></td>
like image 196
Svetoslav Avatar answered Mar 08 '26 18:03

Svetoslav