Shaun13 Posted May 10, 2007 Share Posted May 10, 2007 Ok, I have a script and I have information that a user enters being displayed. I have the information being displayed in tables, but if what you enter is longer than the table, the table gets wider and you have to scroll right to see the whole thing, how can i fix it? Here is the part of the script i am talking about. if(isset($_REQUEST['viewtopic'])) { echo "<table width='100%' border='0' align='center' cellpadding='0' cellspacing='1' bgcolor='#ffffff'> <tr> <td><table width='900' border='0' cellpadding='3' cellspacing='1' bordercolor='1' bgcolor='#000000'> <tr> <td align='center' bgcolor='#ccddcc' colspan='2'><strong>".$rows2['title']."</strong> </tr> <tr> <td bgcolor='#F8F7F1' align='center'><strong>".$rows2['authordisplay']."</strong><br> <td bgcolor='#F8F7F1'>Date/Time : ".$rows2['datetime']."</td> </tr> <tr> <td bgcolor='#Ffffff' width='200'>User information will eventually go in here. Area under construction.</td> <td bgcolor='#Ffffff' align='top'>".$rows2['content']."</td> </tr> </table></td> </tr> </table> <BR>"; $sql3="SELECT * FROM $tablereplies WHERE questionid='$id' ORDER BY answerid"; $result3=mysql_query($sql3); while($rowsanswers=mysql_fetch_array($result3)) { echo "<table width='100%' border='0' align='center' cellpadding='0' cellspacing='1' bgcolor='#ffffff'> <tr> <td><table width='900' border='0' cellpadding='3' cellspacing='1' bgcolor='#000000'> <tr> <td bgcolor='#F8F7F1' align='center'><strong>".$rowsanswers['authordisplay']."</strong></td> <td bgcolor='#F8F7F1'>".$rowsanswers['datetime']."</td> </tr> <tr> <td bgcolor='#ffffff' width='200'>User information will eventually go in here. Area under construction.</td> <td bgcolor='#ffffff' width='700'>".$rowsanswers['content']."</td> </tr> </table></td> </tr> </table><br>"; } if(isset($myusername)) { echo "<table width='400' border='0' align='center' cellpadding='0' cellspacing='1' bgcolor='#CCCCCC'> <tr> <form name='reply' method='post' action='index.php?action=reply'> <td> <table width='100%' border='0' cellpadding='3' cellspacing='1' bgcolor='#FFFFFF'> <tr> <td valign='top'><strong>Post</strong></td> <td valign='top'>:</td> <td><textarea name='content' cols='45' rows='3' id='content'></textarea></td> </tr> <tr> <td> </td> <td><input name='topicid' type='hidden' value='".$id."'></td> <td><input type='submit' name='Submit' value='Submit'> <input type='reset' name='Submit2' value='Reset'></td> </tr> </table> </td> </form>"; } elseif(!isset($myusername)) { echo "<a href='index.php?action=login'>Login</a> to reply to topics!"; } $sql4="SELECT views FROM $tableposts WHERE id='$id'"; $result4=mysql_query($sql4); $rows4=mysql_fetch_array($result4); $views4=$rows4['views']; if(empty($views4)) { $views4=1; $sql5="INSERT INTO $tableposts(views)VALUES('$views4') WHERE id='$id'"; $result5=mysql_query($sql5); } $addview=$views4+1; $sql6="update $tableposts set views='$addview' WHERE id='$id'"; $result6=mysql_query($sql6); } Any help? ~Shaun Quote Link to comment https://forums.phpfreaks.com/topic/50858-some-issues/ Share on other sites More sharing options...
per1os Posted May 10, 2007 Share Posted May 10, 2007 Instead of setting the table width to be 100% Set it to be a certain pixel amount. Generally for 800 res a width of around 650px is fine. Quote Link to comment https://forums.phpfreaks.com/topic/50858-some-issues/#findComment-250135 Share on other sites More sharing options...
Shaun13 Posted May 10, 2007 Author Share Posted May 10, 2007 nope, that didn't work either. ??? ~Shaun Quote Link to comment https://forums.phpfreaks.com/topic/50858-some-issues/#findComment-250139 Share on other sites More sharing options...
per1os Posted May 10, 2007 Share Posted May 10, 2007 This is really more HTML than php my friend. <table width='900' border='0' cellpadding='3' cellspacing='1' bgcolor='#000000'> That width of 900 can be screwing you, especially on a table inside another table. I would maybe fix that to something quite a bit smaller. Quote Link to comment https://forums.phpfreaks.com/topic/50858-some-issues/#findComment-250145 Share on other sites More sharing options...
Shaun13 Posted May 10, 2007 Author Share Posted May 10, 2007 Nope, same result. And I suppose this could be HTML ~Shaun Quote Link to comment https://forums.phpfreaks.com/topic/50858-some-issues/#findComment-250156 Share on other sites More sharing options...
per1os Posted May 10, 2007 Share Posted May 10, 2007 If it is because you are letting a string such as: thisisareallylongstingwithnobreaksatallthatwilthrowoffthehtmlsettingsonthispagethisisareallylongstingwithnobreaksatallthatwilthrowoffthehtmlsettingsonthispagethisisareallylongstingwithnobreaksatallthatwilthrowoffthehtmlsettingsonthispage You should look into www.php.net/wordwrap Quote Link to comment https://forums.phpfreaks.com/topic/50858-some-issues/#findComment-250159 Share on other sites More sharing options...
Shaun13 Posted May 10, 2007 Author Share Posted May 10, 2007 Ok, i checked out that wordwrap thing, thanks, but it isn't working for me. Heres what I have: $sql3="SELECT * FROM $tablereplies WHERE questionid='$id' ORDER BY answerid"; $result3=mysql_query($sql3); while($rowsanswers=mysql_fetch_array($result3)) { $replycontent=$rowsanswers['content']; $replycontentwrap = wordwrap($replycontent, 200, "<br />\n"); echo "<table width='100%' border='0' align='center' cellpadding='0' cellspacing='1' bgcolor='#ffffff'> <tr> <td><table width='100%' border='0' cellpadding='3' cellspacing='1' bgcolor='#000000'> <tr> <td bgcolor='#F8F7F1' align='center'><strong>".$rowsanswers['authordisplay']."</strong></td> <td bgcolor='#F8F7F1'>".$rowsanswers['datetime']."</td> </tr> <tr> <td bgcolor='#ffffff' width='20%'>User information will eventually go in here. Area under construction.</td> <td bgcolor='#ffffff' width='80%'>".$replycontentwrap."</td> </tr> </table></td> </tr> </table><br>"; } Quote Link to comment https://forums.phpfreaks.com/topic/50858-some-issues/#findComment-250179 Share on other sites More sharing options...
Shaun13 Posted May 10, 2007 Author Share Posted May 10, 2007 Can anyone help me out? ~Shaun Quote Link to comment https://forums.phpfreaks.com/topic/50858-some-issues/#findComment-250184 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.