Jump to content

How can I stop the output from expanding the width of the page?


proud

Recommended Posts

 

 

I designed a simple html form containing a text area used to submit letters with the following code:

<form name="form1" method="post" >

<textarea name="a_answer" cols="45" rows="5" id="a_answer"></textarea>

</form>

 

After that I inserted the form data to a mysql database containing a table with one field of type text...

 

My problem is that when I retrieve the data from the database the text is output in the browser in a one long horizontal line expanding the width of the whole page that i have to move the horizontal scroll-bar all the way to see the output of my message...

 

So how can i let the output of the text inside a text area so that it wont affect the width of the page itself, but putting on consideration that the text cant be modified or deleted etc...

 

By the way any other suggestions that can lead to the solution of the problem are appreciated...

 

 

This is the code of the page where I print the data...

Note: The red part of the code is the php code used to retrieve the data from the database....

 

 

<?php

 

$tbl_name2="forum_answer"; // Switch to table "forum_answer"

 

$sql2="SELECT * FROM $tbl_name2 WHERE question_id='$id'";

$result2=mysql_query($sql2);

 

while($rows=mysql_fetch_array($result2)){

?>

 

<table width="400" border="0" align="center" cellpadding="0" cellspacing="1"

bgcolor="#CCCCCC">

<tr>

<td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">

<tr>

<td bgcolor="#F8F7F1"><strong>ID</strong></td>

<td bgcolor="#F8F7F1">:</td>

<td bgcolor="#F8F7F1"><?php echo $rows['a_id']; ?></td>

</tr>

<tr>

<td width="18%" bgcolor="#F8F7F1"><strong>Name</strong></td>

<td width="5%" bgcolor="#F8F7F1">:</td>

<td width="77%" bgcolor="#F8F7F1"><?php echo $rows['a_name']; ?></td>

</tr>

 

<tr>

<td bgcolor="#F8F7F1"><strong>Answer</strong></td>

<td bgcolor="#F8F7F1">:</td>

<td bgcolor="#F8F7F1">

<?php echo $rows['a_answer']; ?></td>

</tr>

<tr>

<td bgcolor="#F8F7F1"><strong>Date/Time</strong></td>

<td bgcolor="#F8F7F1">:</td>

<td bgcolor="#F8F7F1"><?php echo $rows['a_datetime']; ?></td>

</tr>

</table></td>

</tr>

</table>

Nested Tables...icky.

Try printing it out using <p> or <div>, or <span> - something easier to read and maintain.

If you have to use a table, there's no reason to nest them.

<?php

$tbl_name2="forum_answer";
$sql2="SELECT * FROM $tbl_name2 WHERE question_id='$id'";
$result2=mysql_query($sql2) or die(mysql_error());
while($rows=mysql_fetch_array($result2)){
?>
<p><strong>ID</strong>:<?php echo $rows['a_id']; ?><br />
<strong>Name</strong>:<?php echo $rows['a_name']; ?><br />
<strong>Answer</strong>:<?php echo $rows['a_answer']; ?><br />
<strong>Date/Time</strong>:<?php echo $rows['a_datetime']; ?></p>
<?
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.