I have a table that contains 144 records read in from a mysql database table. It's encapsulated in a div tag for the sole purpose of making the height fixed and scrollable. However, it seems that I can't place anything under the table. I wanted to put some contact information and such just using simple <p> tags and nothing appeared. I took the table out, and it displayed.

Anyone else get weird problems like this? How did you fix it?

Otherwise, is there a way I can make a table scrollable? To eliminated putting it inside <div> tag?

thanks,

Is your code look like this:

<div style="overflow:scroll;height:100px;width:40px;">
  <table border="1">
     <tr>
      <td>No</td><td>Name</td>
    </tr>
     <tr>
      <td>1</td><td>Abc </td>
    </tr>
  <tr>
      <td>2</td><td>Pqr </td>
    </tr>
  </table>
</div>

The missing material might be literally UNDER the table, with the table covering it up.

Div tags and table tags don't mix well. The div often renders the wrong size when div and a table are nested. This is especially true if the table can change size dynamically.

Note that dynamic rendering does not normally re-render other objects.

Can't you just put the contact info in it's own div, under the div that scrolls the table?

Like:

<div style="margin: 0 auto; width: 300px; height: 250px; overflow: scroll;">
    <table>
        <tr>
            <th>ID #</th>
            <th>Name</th>
            <th>Something</th>
        </tr>
    <?php for($i = 0; $i < 100; $i++) { ?>
        <tr>
            <td><?php echo $i; ?></td>
            <td>John Doe</td>
            <td><?php echo mt_rand(100, 999); ?></td>
        </tr>
    <?php } ?>
    </table>
</div>
<div style="margin: 0 auto; width: 300px; text-align: center">
    <a href="mailto:example@example.com">Contact Me</a>
</div>

No, I can't put the contact info in it's own <div> tag. It still doesn't appear.

My code is essentially the same as what you had asked adatapost, except it's formatted through a style sheet. I'm beginning to think that it may literally be UNDER the table, like what midimagic had suggested. Because my table is dynamically growing or shrinking in length.

Not that liekly though. I would have thought echoing out 144 records would most likely give you a memory error.

I would have thought that using a style attribute on the p tag to make it display as block and using "clear" with the value of "both" this should make sure it is on it's own line and doesn't appear under the table its self.

Try validating the source HTML (view the page and hit ctrl + S) and submit it to the W3C html validator and check for any HTML errors. It maybe that you are missing an opening or closing tag.

Please post your WHOLE document including the query and the loop.

Not that liekly though. I would have thought echoing out 144 records would most likely give you a memory error.

Why would you think that?

Unless you are fetching them all at once, which is a rather silly thing to do.

He is fetching them all at once. He says displaying 144 records, thats what I mean, would most likely give you a memory error.

He is fetching them all at once. He says displaying 144 records, thats what I mean, would most likely give you a memory error.

I can't agree with you there. I would say it is doubtful that memory limits would be the problem.

144 records aren't really that much. Except if they contain binary data or huge amounts of text.

I mean, by default, PHP 5.1 allows a script to consume 8MBs of memory (16MB in PHP5.2).
That's ~56.9KB per row, which allows each row a maximum of 58,254 ASCII characters, or anywhere between 19,418 and 29,127 Unicode characters.
(Assuming my calculations are correct.)

That's a lot of data...

He is fetching them all at once. He says displaying 144 records, thats what I mean, would most likely give you a memory error.

I really can't see it being a memory issue. 144 records is nothing. Think of all the applications on your machine that process so many things...

anyway, still having problems.

Can anyone think of a better way to accomplish the table?

I have a table that contains 144 records read in from a mysql database table. It's encapsulated in a div tag for the sole purpose of making the height fixed and scrollable. However, it seems that I can't place anything under the table. I wanted to put some contact information and such just using simple <p> tags and nothing appeared. I took the table out, and it displayed.

Anyone else get weird problems like this? How did you fix it?

Otherwise, is there a way I can make a table scrollable? To eliminated putting it inside <div> tag?

thanks,

Hello,

to me this sounds more like a problem of the CSS attributes rather than a PHP problem.

So I would first try to play with the "display" CSS attribute.

<table style="display: block">
...
<p style="display: block">

If that doesn't help I would try to give the p tag a margintop or some bright background color or something that makes it stand out

<p style="margin-top: 500px; background-color: yellow">

If this still doesn't help use Firefox with the Firebug plug-in an browse the HTML hierarchy to check whether the element is really there. I bet it is and just hidden by some other element.

If this still doesn't help use Firefox with the Firebug plug-in an browse the HTML hierarchy to check whether the element is really there. I bet it is and just hidden by some other element.

Yea, this is a very good idea.
Firebug will tell you exactly where it is.

By the way, did you validate your markup?
Mismatched tags and other such markup errors are very likely to cause these sorts of problems.

Member Avatar for diafol

Have you set the position to 'absolute' so that it's covering up everything below it? Check the page source view in your browser to see if all the data's there.

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.