HEy, som overskriftes siger vil jeg gerne kunne bruge enter/linjeskift i et textarea.
i mit nuværende script kommer det hele i en linje. altså, den registrere ikke mit enter.
Hvad gør jeg ?
her er min kode ( den er lift lang):
<?php
$host="localhost"; // Host name
$username="habber_dk"; // Mysql username
$password=""; // Mysql password
$db_name="habber_dk"; // Database name
$tbl_name="forum_question"; // 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="700" border="0" align="center" cellpadding="0" cellspacing="1" >
<tr>
<td><table width="100%" border="0" cellpadding="3" cellspacing="1" bordercolor="1" >
<tr>
<td ><b><? echo $rows['topic']; ?></b></td>
</tr>
<tr>
<td ><p><? echo $rows['detail']; ?></p></td>
</tr>
<tr>
<td ><p><b>By :</b> <? echo $rows['name']; ?> -- <? echo $rows['datetime']; ?></p> </td>
</tr>
</table></td>
</tr>
</table>
<BR>
<?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="700" border="0" align="center" cellpadding="0" cellspacing="1" >
<tr>
<td><hr><table width="100%" border="0" cellpadding="3" cellspacing="1" >
<tr>
<td><p><? echo $rows['a_name']; ?>:</p></td>
</tr>
<tr>
<td ><p><? echo $rows['a_answer']; ?></p></td>
</tr>
<tr>
</br>
<td ><p><? echo $rows['a_datetime']; ?></p></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 = 1
if(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" >
<tr>
<form name="form1" method="post" action="add_answer.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1">
<tr>
<td width="18%"><b>Name</b></td>
<td width="3%"><b>:</b></td>
<td width="79%"><input name="a_name" type="text" id="a_name" size="45"></td>
</tr>
<tr>
<td valign="top"><b>Answer</b></td>
<td valign="top"><b>:</b></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>
Indlæg senest redigeret d. 29.05.2010 20:18 af Bruger #14878