Jump to content

Some Issues


Shaun13

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

If it is because you are letting a string such as:

 

thisisareallylongstingwithnobreaksatallthatwilthrowoffthehtmlsettingsonthispagethisisareallylongstingwithnobreaksatallthatwilthrowoffthehtmlsettingsonthispagethisisareallylongstingwithnobreaksatallthatwilthrowoffthehtmlsettingsonthispage

 

You should look into

 

www.php.net/wordwrap

Link to comment
Share on other sites

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>";
	}

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.