Forum Moderators: coopster

Message Too Old, No Replies

filling up space

         

thinkingtoo

12:39 pm on Jul 30, 2005 (gmt 0)

10+ Year Member



i have a table with 2 columns. 1st column-menu, 2nd column-content

as you may have imagined, the menu is probably going to take less verticle space than the content, so i would like to put some links ther

basically:
<table><tr>
<td>menu goes here <br> some links to fill up the space<?td>
<td> MAIN CONTENT </td>
</tr></table>

for the space that i have "some links to fill up the space" , i wll put pictures there with links attached to them or just have text links.

can someone tell me how to use php to randomly select a few links out of list i make and print it there?

the other thing (the hard thing) is that i would like that area of links to dynamically resize, directly varying with the amount of content.

so if the content was 800 high, and the menu was 150 high, when the page loads, the links will automatically be 650 high.

ergophobe

4:47 pm on Jul 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




so if the content was 800 high, and the menu was 150 high, when the page loads, the links will automatically be 650 high.

This is extremely difficult to do. Assuming you want to do this with HTML (rather than generating a PDF, for example), you would need to

- control the screen width. That's not too bad for usability as you can assume that most folks have at least 760 pixels (assuming they're not on their phone or PDA of course) and make the few who are sidescroll. Not ideal, but many respected designers think it's just fin.

- control font size and not let the user resize. This is bad for usability and cuts out any visually impaired users and may also cut out folks with resolutions set very high relative to screen size.

Why is this true? Because you have to estimate line breaks. If I have this text


My main content.My main content.My main content.My main content.My main content.My main content.My main content.My main content.My main content.My main content.My main content.

And this text.


Link
Link
Link.

Both take up three lines as I look at them. Change your font sizes dramatically. You can get the main content to take up one line, or probably ten. A single-word link will always take up one line.

So basically, you can't really have the control you want.

You can, however provide some fill, but I think it's best to just resign yourself to a general rule and accept that sometimes these will be radically different in length.

One way would be to have a collection of links in a database and use the (assuming mysql) the RAND() function

$chars_per_line = 100; // experiment until you find a value that works.
$content_size = strlen($main_content);
$num_links = $content_size/$chars_per_line;

$sql = "SELECT anchor_text, url FROM links WHERE active='1' ORDER BY RAND() LIMIT '$num_links'";

This will give you a random selection of N links.