How to build dynamic output inside CSS-defined inline frame

Questions and tutorials related to Cascading Style Sheets *all versions*

Moderators: macek, egami, gesf

shawbapmp
New php-forum User
New php-forum User
Posts: 23
Joined: Mon Sep 06, 2004 6:13 am
Location: Toronto

How to build dynamic output inside CSS-defined inline frame

Postby shawbapmp » Mon Sep 13, 2004 9:45 am

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?

User avatar
swirlee
Moderator
Moderator
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Postby swirlee » Mon Sep 13, 2004 10:16 am

It sounds like you're using absolute positioning (i.e. position:absolute) for your divs, and you shouldn't be.

shawbapmp
New php-forum User
New php-forum User
Posts: 23
Joined: Mon Sep 06, 2004 6:13 am
Location: Toronto

Postby shawbapmp » Mon Sep 13, 2004 10:54 am

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?

User avatar
swirlee
Moderator
Moderator
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Postby swirlee » Mon Sep 13, 2004 1:05 pm

Can you post what the outputted HTML looks like?

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

shawbapmp
New php-forum User
New php-forum User
Posts: 23
Joined: Mon Sep 06, 2004 6:13 am
Location: Toronto

Postby shawbapmp » Mon Sep 13, 2004 2:50 pm

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?

User avatar
swirlee
Moderator
Moderator
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Postby swirlee » Mon Sep 13, 2004 3:00 pm

shawbapmp wrote: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.

shawbapmp
New php-forum User
New php-forum User
Posts: 23
Joined: Mon Sep 06, 2004 6:13 am
Location: Toronto

Postby shawbapmp » Mon Sep 13, 2004 4:01 pm

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.

User avatar
swirlee
Moderator
Moderator
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Postby swirlee » Mon Sep 13, 2004 6:34 pm

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: Select all

<div id="MyFrame">

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

</div>

shawbapmp
New php-forum User
New php-forum User
Posts: 23
Joined: Mon Sep 06, 2004 6:13 am
Location: Toronto

Postby shawbapmp » Tue Sep 14, 2004 6:13 am

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!


Return to “CSS”

Who is online

Users browsing this forum: No registered users and 1 guest

cron