Displaying & formatting text with mysql database

This is a discussion on Displaying & formatting text with mysql database within the PHP Language forums, part of the PHP Programming Forums category; I need some help with formatting some text received from a database query. I am only selecting a single row ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-07-2003
Robert
 
Posts: n/a
Default Displaying & formatting text with mysql database

I need some help with formatting some text received from a database
query. I am only selecting a single row per query so the formatting
will only be performed on a single row. The rows I need to format
upon display to the user are currently in text like so: word1 word2
word3 word4 (note there are only spaces between each word)

I just want to insert a character between each word when displayed. A
dash, for example. I want it to look like this: word1 - word2 - word3
- word4 etc. Its too late to do it b4 I put it in the database, so I
have to do it now. Any ideas?

TIA
Rob
Reply With Quote
  #2 (permalink)  
Old 10-07-2003
Tom Thackrey
 
Posts: n/a
Default Re: Displaying & formatting text with mysql database


On 7-Oct-2003, gojuka@si.rr.com (Robert) wrote:

> I need some help with formatting some text received from a database
> query. I am only selecting a single row per query so the formatting
> will only be performed on a single row. The rows I need to format
> upon display to the user are currently in text like so: word1 word2
> word3 word4 (note there are only spaces between each word)
>
> I just want to insert a character between each word when displayed. A
> dash, for example. I want it to look like this: word1 - word2 - word3
> - word4 etc. Its too late to do it b4 I put it in the database, so I
> have to do it now. Any ideas?


I'm not totally clear on the question but try this:

// assuming $row has been retrieved from the database
$fieldwithdashes = str_replace(' ',' - ',$row['fieldname']);
echo $fieldwithdashes;

--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to jamesbutler@willglen.net (it's reserved for spammers)
Reply With Quote
  #3 (permalink)  
Old 10-07-2003
Matthias Esken
 
Posts: n/a
Default Re: Displaying & formatting text with mysql database

"Tom Thackrey" <use.signature@nospam.com> schrieb:

> // assuming $row has been retrieved from the database
> $fieldwithdashes = str_replace(' ',' - ',$row['fieldname']);


I just wanted to post something with regular expressions. Glad you were
first. :-)

Regards,
Matthias
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:39 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0