Jump to content

>> My Tables Aren't Wrapping Right! Please Help!!


kickindrummerkid

Recommended Posts

My tables are becoming messed up when posting more the one line... like having multiple lines.  Please help, below has code and images.  If you need to contact me other then this forum you can email me at kickindrummerkid@gmail.com.  Or contact me on AIM at kickindrummerkid.  Or on MSN at kickindrummerkid@hotmail.com.  Thanks.

Main Page, index.php:
[code]// Grab variables from row
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$username = $row['username'];
$date_posted = $row['date_posted'];
$title = $row['title'];
$post = $row['post'];
$align = $row['align'];

// Wrap variables so tables dont get messed up and expand
$post = wordwrap($post, 69, " ", 1);
?>
<table border="0" cellpadding="0" cellspacing="0" class="table_newspost">
  <tr>
    <td class="td_table_topleft"><div align="center"><img src="images/tables/topleft.jpg" width="14" height="14" /></div></td>
    <td colspan="3" class="td_table_topmiddle td_newspost_topmiddle"><div align="center"></div></td>
    <td class="td_table_topright"><div align="center"><img src="images/tables/topright.jpg" width="14" height="14" /></div></td>
  </tr>
  <tr>
    <td class="td_table_leftmiddle"><div align="center"></div></td>
    <td class="td_newspost_leftheader"><div align="left"><strong>Posted By: <?php echo $username; ?></strong></div></td>
    <td class="td_newspost_middleheader"><div align="center"><strong><?php echo $title; ?></strong></div></td>
    <td class="td_newspost_rightheader"><div align="right"><strong>Date: <?php echo $date_posted; ?></strong></div></td>
    <td class="td_table_rightmiddle"><div align="center"></div></td>
  </tr>
  <tr>
    <td class="td_table_leftmiddle"><div align="center"></div></td>
    <td colspan="3"><div align="justify"><?php echo $post; ?></div></td>
    <td class="td_table_rightmiddle"><div align="center"></div></td>
  </tr>
  <tr>
    <td class="td_table_bottomleft"><div align="center"><img src="images/tables/bottomleft.jpg" width="14" height="14" /></div></td>
    <td colspan="3" class="td_table_bottommiddle"><div align="center"></div></td>
    <td class="td_table_bottomright"><div align="center"><img src="images/tables/bottomright.jpg" width="14" height="14" /></div></td>
  </tr>
</table><?php if($id != 1){ ?><br /><?php echo "\n"; } ?>
<?php
}

// Grab database_disconnect function and disconnects from mysql
funct_database_disconnect();

// Grab newline function for bottom
funct_insert_newline();
funct_insert_newline();

?>[/code]

CSS Stylesheet, style.css:
[code]table.table_newspost {  /* Newspost table (table holding the news posts) */
width: 514px;
}
td.td_newspost_topmiddle {  /* Newspost table topmiddle (topmiddle of newspost table) */
width: 486px;
}
td.td_newspost_leftheader {  /* Newspost table leftheader (leftheader of newspost table) */
width: 158px;
}
td.td_newspost_middleheader {  /* Newspost table leftheader (leftheader of newspost table) */
width: 170px;
}
td.td_newspost_rightheader {  /* Newspost table rightheader (rightheader of newspost table) */
width: 158px;
}[/code]


Ok, now here is the picture.  As you can see, the bottom post only has one line... so the title/table doesn't get all messed up and expand and stuff.  On the first post (top) it goes over multiple lines and the title and tables get all messed up and I have no clue why.  Please help.  Thanks.
[img]http://www.sypherro.dynamitehosting.net/cta/Error.jpg[/img]

Any help offered is a big deal, thanks everyone.
Link to comment
Share on other sites

yes either change the /n command to </ br>
and try that and i didnt mean remove word wrap
what i meant was after
[code]
$post = wordwrap($post, 69, " ", 1);
//put
$post = nl2br($post);
[/code]
the wordwrap will keep your line from going for ever and the nl2br will automatically add </ br> where ever its need like you know when you record something from a text area into a longtext type mysql row when a person pressed enter it goes to a new line your post is not going to a new line thats why you need
nl2br in there well hope im not confusing

main point is that the reason i think its not making multiple lines is the /n should be changed to
</ br>/n this will start a new line when you want it (after 69 characters) and nl2br should be added that will start a new line when the poster wants it.
Link to comment
Share on other sites

lol ;)... i dont have a \n command... look at the picture.  you see... the text wraps when there is a space inserted...  so if somebudy was going to type "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" forever it wud never wrap without the WORDWRAP function I added.  Which, at every 69 characters, it adds a space so the text will wrap and won't make the table resize to be bigger.  But, I'm still having problems with the TDs above when the text goes on multiple lines.  I've tried your thing and it doesn't work, and I knew it wouldn't because were both talking about different topics.

see... what ur confused about is ur thinking im putting a new line in.. which i never am... im just adding a space so the text wraps without putting a new line in.

also... I DO have that command with the ENTER button and the new lines and it DOES put a BR in...  but that isn't my problem.  the multiple lines u see in the first post automatically wrap and I never pressed the enter button the whole time.  your talking about the enter button and making BRs with it.. i have that already... i need to figure out why the TDs are getting messed up when my lines wrap over though.

EDIT: If i make it put BRs when it gets to character 69 it does wrap and the TDs don't get messed up... but it wraps before the text reaches the end of the TD depending on how wide the characters are... I just want the characters to wrap at the end of the TD so the table doesn't expand and I don't know how to do that.
Link to comment
Share on other sites

Have you tried changing 69 to 68 in your text wrap function?  Or alternatively stick in another

<table border="0" cellpadding="0" cellspacing="0" width="486">
  <tr>

just under your middle row with the $post in and close it after your <td's> I know it's a bit messy but will stop it messing up the cells in the row above.  If anyone knows a better way, I'd like to know also.
Link to comment
Share on other sites

well making it 68 doesnt work either...  so it still doesnt make difference. whenever it laps over it gets messed up.  putting a table there works... but if somebudy uses a character like "l" (lowercase L).. and just spams it.. it gets cut off early because the L width is smaller then the other characters.  So it goes to 69 and gets cut... but it didnt reach the end of the TD.  I need to find a way to let it reach the end and then wrap.
Link to comment
Share on other sites

Try using the table and 68 together.  ;) Or I found this CSS function that might help using visable or auto may do it http://www.w3schools.com/css/pr_pos_overflow.asp I think visable may just display the right edge over the other element, may look OK if your image is big enough down that side.
Link to comment
Share on other sites

u see!!! THE 68 MESSES UP! The text wraps right only if I dont spam the lowercase L... if I do that then it wraps early because the L width is smaller and when it gets to 68 its only like halfway across table.  And the CSS only works in INTERNET EXPLORER... so I need another way to do this.  Thanks.. please help somebudy!
Link to comment
Share on other sites

Look at my example copy and past and see what you think ok.

example.php
[code]
<?php

$line="--------------------------------------------";

$lines=wordwrap($line,22,"<br>",1);

$user="redarrow";

$date=date("d-m-y");


$message="hi there i have looked at your code and i think you need to study the word wrap function good luck";

$result=wordwrap($message,40,"<br>",1);

echo "<table bgcolor='yellow' width='150' border='4' bordercolor='black'><td align='center'>$user<br>$date<br>$lines<br><div

align='left'>$result</div></td></table>";

?>
[/code]
Link to comment
Share on other sites

IM FINE WITH THE WORD-WRAP FUNCTION! ITS JUST THAT THE "L" CHARACTER IS SHORTER THEN OTHER CHARACTERS SO IT WRAPS AT THE RIGHT AMOUNT OF CHARACTERS... BUT WRAPS HALF-WAY ACROSS TABLE BECAUSE THE L CHARACTER WIDTH IS SMALLER... LOOK

"llllllllllllllllllllllllllllllllllllllllllllllllll   is smaller then CCCCCCCCCCCCCCCCCCCCCC" SO IT WRAPS EARLIER!
Link to comment
Share on other sites

[quote]
u see!!! THE 68 MESSES UP! The text wraps right only if I dont spam the lowercase L... if I do that then it wraps early because the L width is smaller and when it gets to 68 its only like halfway across table.  And the CSS only works in INTERNET EXPLORER... so I need another way to do this.  Thanks.. please help somebudy!
[/quote]

Actually ive heard that firefox technically has better CSS support than IE... and I'm fairly sure any recent browser supports CSS...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.