how to save TAB delimited list
I try to copy and paste TAB delimited list into html text area, then save it to database, however when I retrieve it from DB, all TAB space are gone, does anyone can give me advice is there a way to keep these TAB?
Thanks in advance.
test test test <----regular space
==============
test test test <----one TAB space
test test test <----two TAB spaces
when I retrieve from DB, it shows:
test test test
==============
test test test
test test test
P.S. The DB field is TEXT datatype (I use MSSQL)
michael123
Junior Poster in Training
94 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
You can also use tag.
http://www.w3schools.com/TAGS/tag_pre.asp
<?php
mysql_connect("localhost","root");
mysql_select_db("test");
if(isset($_POST['submit'])) {
mysql_query("insert into tst (name) values ('".$_POST['tarea']."')");
}
?>
<html>
<body>
<form method="post">
<textarea name="tarea" cols="30" rows="20"></textarea>
<input type='submit' name="submit" value="submit">
</form>
</body>
</html>
<?php
$q = "select * from tst";
$r = mysql_query($q);
if(mysql_num_rows($r) > 0 ) {
while($row = mysql_fetch_array($r)) {
echo "<pre>";
echo $row['name'];
echo "</pre>";
echo "";
}
}
?>
Just did a quick check to see if it works and it does..
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
you could try:
str_replace(" ", "\t",$string);
I think that doesn't work.. :-/
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356