SunQuest
           PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Try It Free
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old September 6th, 2002, 02:25 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
Help!? - Want to format large text in a column from database

Hi,
Need some help, I have put a far amount of text in a cell of a table, you can check it out at www.pcguide.com.au/Terms/terms.php3 . a user can search for a term and then database returns results. at the moment when users enters like ATA it comes back with text but all one long text sentence, is there some way i can add a return so its spaced out?
If you can help it would be great!
Thanks
email: ben@pcguide.com.au

Reply With Quote
  #2  
Old September 6th, 2002, 03:22 PM
Nimco Nimco is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 132 Nimco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to Nimco
RE: Help!? - Want to format large text in a column from database

Try this:

php Code:
Original - php Code
  1.  
  2. <?
  3.  $body = eregi_replace("([rn])", "<br>", $body);
  4. ?>

Reply With Quote
  #3  
Old September 6th, 2002, 03:30 PM
guyer guyer is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Bloomington, IN USA
Posts: 47 guyer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via Yahoo to guyer
RE: Help!? - Want to format large text in a column from database

I do this since two <br>'s next to each other sometimes doesn't work as expected:
Code:
<?
$string=str_replace("rnrn", "<p>", $string);
$string=str_replace("rn", "<br>", $string);
?>

Reply With Quote
  #4  
Old September 6th, 2002, 03:35 PM
Nimco Nimco is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 132 Nimco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to Nimco
RE: Help!? - Want to format large text in a column from database

True, my initial post should have included <br><br> anyway - that was a typo - but I agree, it sometimes doesn't do what you would expect. The only reason I prefer it is so that I can use XHTML (I would use "<br /><br />" because XHTML won't validate open tags (e.g. <p> without </p>).

Reply With Quote
  #5  
Old September 7th, 2002, 09:46 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Help!? - Want to format large text in a column from database

if this is the code where would i place the new code to format output??
<?php
$database="Terms";
mysql_connect(localhost,$username,$password);
mysql_select_db($database) or die( "Unable to select database");

$query="SELECT * FROM Terms WHERE Term = '$search_text'";
$result=mysql_query($query);
$num=mysql_num_rows($result);
if ($num==0) {
echo "Sorry we do not have a Definition for this Term. The database is just being setup and Term Definitions are few at the moment. Please try again soon, you can also email your Term question to us for a definition and so we can place it on the database.";
}else{
$Term=mysql_result($result,$i,"Term");
?>
<font size="3" face="Arial, Helvetica, sans-serif">
<?php echo "<b><center>$Term</center></b><br><br>";?>
</font>

<?php
$Term_Definitions=mysql_result($result,$i,"Term_Definitions");
echo "$Term_Definitions<br>";
}
mysql_close();
?>

Thanks!

Reply With Quote
  #6  
Old September 7th, 2002, 09:49 AM
Nimco Nimco is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 132 Nimco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to Nimco
RE: RE: Help!? - Want to format large text in a column from database

php Code:
Original - php Code
  1.  
  2.   <?php
  3. $database="Terms";
  4. mysql_connect(localhost,$username,$password);
  5. mysql_select_db($database) or die( "Unable to select database");
  6.  
  7. $query="SELECT * FROM Terms WHERE Term = '$search_text'";
  8. $result=mysql_query($query);
  9. $num=mysql_num_rows($result);
  10. if ($num==0) {
  11. echo "Sorry we do not have a Definition for this Term. The database is just being setup and Term Definitions are few at the moment. Please try again soon, you can also email your Term question to us for a definition and so we can place it on the database.";
  12. }else{
  13. $Term=mysql_result($result,$i,"Term");
  14. ?>
  15. <font size="3" face="Arial, Helvetica, sans-serif">
  16. <?php echo "<b><center>$Term</center></b><br><br>";?>
  17. </font>
  18.  
  19. <?php   
  20. $Term_Definitions=mysql_result($result,$i,"Term_Definitions");
  21. $Term_Definitions=str_replace("rnrn", "<p>", $Term_Definitions);
  22. $Term_Definitions=str_replace("rn", "<br>", $Term_Definitions);
  23. echo "$Term_Definitions<br>";
  24. }
  25. ?>

Reply With Quote
  #7  
Old September 8th, 2002, 05:30 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Help!? - Want to format large text in a column from database

Thanks it works great!
you can check it out at our site.
www.pcguide.com.au
try ATA, gives good explain, as there is not much on the database as yet!
thanks again

Reply With Quote
  #8  
Old September 8th, 2002, 03:34 PM
Nimco Nimco is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 132 Nimco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to Nimco
RE: Help!? - Want to format large text in a column from database

No problem. Site looks good.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Help!? - Want to format large text in a column from database


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway