oetzen88 Posted November 19, 2011 Share Posted November 19, 2011 Hello there, i got a problem with my guestbook. If i enter a message in my guestbook with a verry long line, the line wont break. can someone help me with this. example: www.dewittearend.nl/gastenboek.php This is my php code. <?php if(!isset($_GET['page'])){ $page = 0; } else { $page = $_GET['page'] * $items; } $query = mysql_query("SELECT * FROM `entries`"); $rows = mysql_num_rows($query); $query = mysql_query("SELECT *, UNIX_TIMESTAMP(`date`) as date FROM `entries` ORDER BY `date` DESC LIMIT ".$page.",".$items.""); ?> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <?php while($row = mysql_fetch_array($query)){ if(($i % 2) == 0){ $class = 'class="entry1"'; $classbg = 'class="entriesbg1"'; } else { $class = 'class="entry2"'; $classbg = 'class="entriesbg2"'; } ?> <tr> <td valign="top" <?php echo $classbg; ?>> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td valign="top" class="entrysmall" align="right">#<?php echo $rows - ($page)-$i; ?> Posted on: <?php echo date("d/m/y g:i a", $row['date']); ?></td> </tr> <tr> <td valign="top"> <table width="100%" cellpadding="0" cellspacing="0" border="0" <?php echo $class; ?>> <tr> <td valign="top" style="padding-right: 10px;"><span class="entrytitle">Name:</span></td> <td valign="bottom" width="100%"><?php echo htmlspecialchars(stripslashes($row['name'])); ?></td> </tr> <tr> <td valign="top" style="padding-right: 10px;" nowrap="nowrap"><span class="entrytitle">E-Mail:</span></td> <td valign="bottom" width="100%"><?php $email = explode('@',stripslashes($row['email'])); echo $email[0].' *at* '.$email[1]; ?></td> </tr> <?php if(strlen($row['website']) > 0){ if(substr(strtolower($row['website']), 0, 7) != 'http://'){ $website = 'http://'.$row['website']; } else { $website = $row['website']; } ?> <tr> <td valign="top" style="padding-right: 10px;" nowrap="nowrap"><span class="entrytitle">Website:</span></td> <td valign="bottom" width="100%"><a href="<?php echo stripslashes($website); ?>" target="_blank"><?php echo htmlspecialchars(substr($website,0,30)); ?></a></td> </tr> <?php } ?> <tr> <td valign="top" style="padding: 5px 10px 0px 0px;" colspan="2"><span class="entrytitle">Message:</span></td> </tr> <tr> <td valign="top" style="padding-right: 10px;" colspan="2"><?php echo smilies (htmlspecialchars(stripslashes($row['message']))); ?></td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td valign="top" height="10"></td> </tr> <?php $i++;} ?> </table> Quote Link to comment https://forums.phpfreaks.com/topic/251432-guestbook-problem/ Share on other sites More sharing options...
Pikachu2000 Posted November 19, 2011 Share Posted November 19, 2011 Translate your question to English, and enclose any code you post within . . . tags. Quote Link to comment https://forums.phpfreaks.com/topic/251432-guestbook-problem/#findComment-1289530 Share on other sites More sharing options...
oetzen88 Posted November 19, 2011 Author Share Posted November 19, 2011 Hello, I got a problem with my guestbook, and just spend allot of hours in it. But cant figure it out. If i enter a message in my guestbook with a verry long line, the line wont break. Can someone help me with this. Click on the link to see my problem: www.dewittearend.nl/gastenboek.php This is the php code (i didnt wrote this code by myself). Sorry for my bad english. <?php if(!isset($_GET['page'])){ $page = 0; } else { $page = $_GET['page'] * $items; } $query = mysql_query("SELECT * FROM `entries`"); $rows = mysql_num_rows($query); $query = mysql_query("SELECT *, UNIX_TIMESTAMP(`date`) as date FROM `entries` ORDER BY `date` DESC LIMIT ".$page.",".$items.""); ?> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <?php while($row = mysql_fetch_array($query)){ if(($i % 2) == 0){ $class = 'class="entry1"'; $classbg = 'class="entriesbg1"'; } else { $class = 'class="entry2"'; $classbg = 'class="entriesbg2"'; } ?> <tr> <td valign="top" <?php echo $classbg; ?>> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td valign="top" class="entrysmall" align="right">#<?php echo $rows - ($page)-$i; ?> Posted on: <?php echo date("d/m/y g:i a", $row['date']); ?></td> </tr> <tr> <td valign="top"> <table width="100%" cellpadding="0" cellspacing="0" border="0" <?php echo $class; ?>> <tr> <td valign="top" style="padding-right: 10px;"><span class="entrytitle">Name:</span></td> <td valign="bottom" width="100%"><?php echo htmlspecialchars(stripslashes($row['name'])); ?></td> </tr> <tr> <td valign="top" style="padding-right: 10px;" nowrap="nowrap"><span class="entrytitle">E-Mail:</span></td> <td valign="bottom" width="100%"><?php $email = explode('@',stripslashes($row['email'])); echo $email[0].' *at* '.$email[1]; ?></td> </tr> <?php if(strlen($row['website']) > 0){ if(substr(strtolower($row['website']), 0, 7) != 'http://'){ $website = 'http://'.$row['website']; } else { $website = $row['website']; } ?> <tr> <td valign="top" style="padding-right: 10px;" nowrap="nowrap"><span class="entrytitle">Website:</span></td> <td valign="bottom" width="100%"><a href="<?php echo stripslashes($website); ?>" target="_blank"><?php echo htmlspecialchars(substr($website,0,30)); ?></a></td> </tr> <?php } ?> <tr> <td valign="top" style="padding: 5px 10px 0px 0px;" colspan="2"><span class="entrytitle">Message:</span></td> </tr> <tr> <td valign="top" style="padding-right: 10px;" colspan="2"><?php echo smilies (htmlspecialchars(stripslashes($row['message']))); ?></td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td valign="top" height="10"></td> </tr> <?php $i++;} ?> </table> Quote Link to comment https://forums.phpfreaks.com/topic/251432-guestbook-problem/#findComment-1289551 Share on other sites More sharing options...
Pikachu2000 Posted November 19, 2011 Share Posted November 19, 2011 There are a couple ways to handle this. One of them is with php's wordwrap function, and another would be with CSS's word-wrap:break_word attribute. If you allow html tags to be used, the php function may end up chopping a line in the middle of a tag, and it may not be suitable for use with a non-fixed-width font. Quote Link to comment https://forums.phpfreaks.com/topic/251432-guestbook-problem/#findComment-1289564 Share on other sites More sharing options...
oetzen88 Posted November 21, 2011 Author Share Posted November 21, 2011 Thank you for your fast reply. I tried this two things, but somehow it doesnt work. More idea's? This is the css script. html,body { background: #222222; color: #FFFFFF; font-family: "HelveticaNeue-UltraLight", Helvetica, Arial, Verdana, Courier; font-size: 16px; } .guestbookform { padding: 10px; border: #999999 solid 1px; background: #333333; } input, textarea { border: #999999 solid 1px; width: 100%; resize: none; background: #FFFFFF; color: #222222; } a { color: #FFFFFF; text-decoration: none; } a:hover { text-decoration: underline; } form, input { padding: 0px; margin: 0px; } .errors { border: #999999 solid 1px; color: #222222; background: #ffe958; font-size: 14px; padding: 10px; } .errorbg { background: #ffe958; } .success { border: #999999 solid 1px; color: #FFFFFF; background: #36c952; font-size: 14px; padding: 10px; } .entries { padding: 10px 10px 0px 10px; border: #999999 solid 1px; font-size: 14px; background: #333333; } .entriesbg2 { padding: 10px; border: #999999 solid 1px; font-size: 14px; background: #111111; } .entriesbg1 { padding: 10px; border: #999999 solid 1px; font-size: 14px; background: #555555; } .entrytitle { font-family: Helvetica, Arial, Verdana, Courier; } .entrysmall { font-size: 12px; } .entry1 { padding: 5px; margin: 2px; border: #222222 solid 1px; background: url('../images/entry2.jpg') repeat-x #000000; } .entry2 { padding: 5px; margin: 2px; border: #555555 solid 1px; background: url('../images/entry1.jpg') repeat-x #333333; } .pagination { font-size: 14px; } Quote Link to comment https://forums.phpfreaks.com/topic/251432-guestbook-problem/#findComment-1290128 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.