471,306 Members | 854 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,306 software developers and data experts.

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
Jul 17 '05 #1
2 4181

On 7-Oct-2003, go****@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 ja*********@willglen.net (it's reserved for spammers)
Jul 17 '05 #2
"Tom Thackrey" <us***********@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
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by James | last post: by
7 posts views Thread by AF | last post: by
1 post views Thread by Tim | last post: by
2 posts views Thread by donpro | last post: by
George Lft
1 post views Thread by George Lft | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.