How to build dynamic output inside CSS-defined inline frame

  • Thread starter Thread starter Anonymous
  • Start date Start date
A

Anonymous

Guest
I'm a Newbie,

One of your experts on this forum got me going on a little PHP page which sets up a CSS scrollbar inline frame to display the output of my database. Trouble is, the records keep overwriting each other while the PHP code loops through all the DB records, resulting in a display that looks like a defective printer that prints a whole page on one line. When I move the </div> closing attribute to the end of the DIV ID line, the records display correctly one after the other, but at the bottom of the HTML page. Clearly, the output is repeating the format defined in the DIV ID line over and over for each record in the database.

Can someone advise me how to have the records build dynamically (one below the other) inside my CSS frame?
 
It sounds like you're using absolute positioning (i.e. position:absolute) for your divs, and you shouldn't be.
 
Hi Swirlee,
I'm sure you are right. But which DIVs should I be changing? I tried using position: relative but that didn't work. Maybe it would help if I showed you my code:

<div id="MyFrame" style="position: absolute; left: 10%; top: 200; width: 300; height: 200">
<font face="Arial" size="2">PHP Variable1 Name: '.$var1name.'</font></br>
<font face="Arial" size="2">PHP Variable2 Name: '.$var2name.'</font></br>
</div>

The above code produces output within the CSS frame "MyFrame" but Variables 1 and 2 get overwritten for each occurrence in the DB. If I move the </div> to the end of the <div id.. line, the output is not overwritten, but appears outside the CSS frame.

Can you comment on what I should be doing?
 
Can you post what the outputted HTML looks like?

It seems to me that you must be outputting the "MyFrame" div multiple times.
 
Hi Swirlee,

I'm not sure how I can easily post the output, which is actually a self-posting PHP script that echoes the entire HTML page, along with the records extracted from my database.

You are right in concluding that my CSS scrollable frame is output multiple times. In fact, it is output for each record processed. Logically it makes more sense to have the CSS frame echoed once, and then the output lines echoed multiple times for each record processed. But when I do that, the output variable lines stubbornly list themselves at the bottom of the HTML page, outside the scrollable frame. I can't seem to format the output variable lines to go inside the frame.

Am I making sense?
 
shawbapmp said:
I'm not sure how I can easily post the output, which is actually a self-posting PHP script that echoes the entire HTML page, along with the records extracted from my database.

View > Source in your browser.

Logically it makes more sense to have the CSS frame echoed once, and then the output lines echoed multiple times for each record processed. But when I do that, the output variable lines stubbornly list themselves at the bottom of the HTML page, outside the scrollable frame.

Just put the code for the div outside of your loop.
 
But then how do I get the dynamically produced output to be contained inside the inline frame? Does not the content of the scrollable area have to be part of the DIV statement?

I believe I have failed to properly communicate the essence of this problem. I will review some HTML reference material and try to resolve this on my own, rather than waste more of your time.

Thank you kindly for the guidance you have given me.

Cheers.
 
Put the opening tag of the div before the loop.

Put the bits that go inside the div inside the loop.

Put the closing tag of the div after the loop.

e.g.:
Code:
<div id="MyFrame">

<?php
while($condition) {
   echo 'PHP Variable1 Name: ' . $var1name . '<br/>';
   echo 'PHP Variable2 Name: ' . $var2name . '<br/>';
}
?>

</div>
 
Hi Swirlee,

Now I feel really stupid. Moving that /DIV outside the PHP code did the trick. That was simple processing logic that should have been obvious to me. I guess sometimes having someone else's perspective helps.

Thanks for your patience.

I can take it from here...duh!
 
Back
Top