943,935 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 2406
  • PHP RSS
Jun 20th, 2008
0

how to save TAB delimited list

Expand Post »
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.

PHP Syntax (Toggle Plain Text)
  1. test test test <----regular space
  2. ==============
  3. test test test <----one TAB space
  4. test test test <----two TAB spaces

when I retrieve from DB, it shows:
PHP Syntax (Toggle Plain Text)
  1. test test test
  2. ==============
  3. test test test
  4. test test test

P.S. The DB field is TEXT datatype (I use MSSQL)
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
michael123 is offline Offline
93 posts
since Jun 2005
Jun 20th, 2008
1

Re: how to save TAB delimited list

you could try:
php Syntax (Toggle Plain Text)
  1. str_replace(" ", "\t" $string);
Last edited by R0bb0b; Jun 20th, 2008 at 2:13 pm.
Reputation Points: 358
Solved Threads: 89
Posting Shark
R0bb0b is offline Offline
986 posts
since Jun 2008
Jun 20th, 2008
0

Re: how to save TAB delimited list

You can also use <pre> tag.
http://www.w3schools.com/TAGS/tag_pre.asp

php Syntax (Toggle Plain Text)
  1. <?php
  2. mysql_connect("localhost","root");
  3. mysql_select_db("test");
  4. if(isset($_POST['submit'])) {
  5. mysql_query("insert into tst (name) values ('".$_POST['tarea']."')");
  6. }
  7. ?>
  8. <html>
  9. <body>
  10. <form method="post">
  11. <textarea name="tarea" cols="30" rows="20"></textarea>
  12. <input type='submit' name="submit" value="submit">
  13. </form>
  14. </body>
  15. </html>
  16. <?php
  17. $q = "select * from tst";
  18. $r = mysql_query($q);
  19. if(mysql_num_rows($r) > 0 ) {
  20. while($row = mysql_fetch_array($r)) {
  21. echo "<pre>";
  22. echo $row['name'];
  23. echo "</pre>";
  24. echo "<br>";
  25. }
  26. }
  27. ?>
Just did a quick check to see if it works and it does..
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
Jun 20th, 2008
0

Re: how to save TAB delimited list

Click to Expand / Collapse  Quote originally posted by R0bb0b ...
you could try:
php Syntax (Toggle Plain Text)
  1. str_replace(" ", "\t",$string);
I think that doesn't work..
Last edited by nav33n; Jun 20th, 2008 at 2:26 pm.
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Please help in coding
Next Thread in PHP Forum Timeline: Form in one iFrame refreshes another iFrame





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC