how to save TAB delimited list

Reply

Join Date: Jun 2005
Posts: 92
Reputation: michael123 is an unknown quantity at this point 
Solved Threads: 0
michael123 michael123 is offline Offline
Junior Poster in Training

how to save TAB delimited list

 
0
  #1
Jun 20th, 2008
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.

  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:
  1. test test test
  2. ==============
  3. test test test
  4. test test test

P.S. The DB field is TEXT datatype (I use MSSQL)
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 849
Reputation: R0bb0b is on a distinguished road 
Solved Threads: 67
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Practically a Posting Shark

Re: how to save TAB delimited list

 
1
  #2
Jun 20th, 2008
you could try:
  1. str_replace(" ", "\t" $string);
Last edited by R0bb0b; Jun 20th, 2008 at 2:13 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,748
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: how to save TAB delimited list

 
0
  #3
Jun 20th, 2008
You can also use <pre> tag.
http://www.w3schools.com/TAGS/tag_pre.asp

  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..
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,748
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: how to save TAB delimited list

 
0
  #4
Jun 20th, 2008
Originally Posted by R0bb0b View Post
you could try:
  1. str_replace(" ", "\t",$string);
I think that doesn't work..
Last edited by nav33n; Jun 20th, 2008 at 2:26 pm.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC