XxDeadmanxX Posted January 21, 2007 Share Posted January 21, 2007 Im try make simple forum but the message if its to big it makes the table bigger.http://afrosf.af.funpic.org/1/view_topic.php?id=1And here i the script:[code]<?php$host="localhost"; // Host name $username="xxxxxxxx"; // Mysql username $password="xxxxxx"; // Mysql password $db_name="xxxxxxxxxxxx"; // Database name $tbl_name="xxxxxxxxxxxxxxxx"; // Table name // Connect to server and select databse.mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB");// get value of id that sent from address bar $id=$_GET['id'];$sql="SELECT * FROM $tbl_name WHERE id='$id'";$result=mysql_query($sql);$rows=mysql_fetch_array($result);?><table width="400" border="1" align="center" bordercolor="gray" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC"><tr><td><table width="400" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC"><tr><td><table width="100%" border="1" cellpadding="3" cellspacing="1" bordercolor="1" bgcolor="#FFFFFF"><tr><th bgcolor="#F8F7F1"><strong><? echo $rows['topic']; ?></strong></th></tr></table></td></tr></table><table width="400" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC"><tr><td><table width="100%" border="1" cellpadding="3" cellspacing="1" bordercolor="1" bgcolor="#FFFFFF"><tr><th bgcolor="#F8F7F1" width="100">Author</th><th bgcolor="#F8F7F1">Message</th></tr><tr><td bgcolor="#F8F7F1" width="100"><? echo $rows['name']; ?> <br> <strong>Date/time : </strong><? echo $rows['datetime']; ?></td><td bgcolor="#F8F7F1"> <? echo $rows['detail']; ?></td></tr></table></td></tr></table><?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="1" cellspacing="1" bgcolor="#CCCCCC"><tr><td><table width="100%" border="1" cellpadding="3" cellspacing="1" bordercolor="1" bgcolor="#FFFFFF"><tr><th bgcolor="#F8F7F1" width="100">Author</th><th bgcolor="#F8F7F1">Message</th></tr><tr><td bgcolor="#F8F7F1" width="100"><? echo $rows['a_name']; ?></td><td bgcolor="#F8F7F1"><? echo $rows['a_answer']; ?></td></tr></table></td></tr></table></td></tr></table><br><?}$sql3="SELECT view FROM $tbl_name WHERE id='$id'";$result3=mysql_query($sql3);$rows=mysql_fetch_array($result3);$view=$rows['view'];// if have no counter value set counter = 1if(empty($view)){$view=1;$sql4="INSERT INTO $tbl_name(view) VALUES('$view') WHERE id='$id'";$result4=mysql_query($sql4);}// count more value$addview=$view+1;$sql5="update $tbl_name set view='$addview' WHERE id='$id'";$result5=mysql_query($sql5);mysql_close();?><BR><table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"><tr><form name="form1" method="post" action="add_answer.php"><td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"><tr><td width="18%"><strong>Name</strong></td><td width="3%">:</td><td width="79%"><input name="a_name" type="text" id="a_name" size="45"></td></tr><tr><td><strong>Email</strong></td><td>:</td><td><input name="a_email" type="text" id="a_email" size="45"></td></tr><tr><td valign="top"><strong>Answer</strong></td><td valign="top">:</td><td><textarea name="a_answer" cols="45" rows="3" id="a_answer"></textarea></td></tr><tr><td> </td><td><input name="id" type="hidden" value="<? echo $id; ?>"></td><td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td></tr></table></td></form></tr></table>[/code] Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 21, 2007 Share Posted January 21, 2007 This isn't a PHP issue. If the number of characters is too large, the HTML has to expand.What you could do is check all the messages for strings which are too long without spaces, and cut them up. Most forums just let the page get stretched. It'll probably help if you give more than 300 pixels for the text. Quote Link to comment 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.