473,222 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,222 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 4326

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: James | last post by:
HI, I'm looking for a script that will allow users/admins to have a one click backup solution for a MYSQL Database.. 'BACK DATABASE' button, click and its done... The a restore option, that...
7
by: AF | last post by:
I am a real novice to php and MySQL, with about a week's worth of reading and self tutoring. I have an urgent need to publish a database of information and need some guidance on how to do this. ...
1
by: Tim | last post by:
Hi Guys I have a mysql database that contains guitar tabs and song lyrics (kind of like my own personal taborama.com),anyway i have everything stored in the database and use php to display all...
1
by: Dave Posh | last post by:
I seem to be having a problem displaying time stored in mysql. The format stored in the database is 13:15:05. The database data type is time. I'm using asp vbscript and sql to retrieve the time...
4
by: MLH | last post by:
A programmer developed an AMP (Apache/MySQL/PHP) application for me. When he was done, he sent me the PHP files and the MySQL dump file. Now, when I connect to the application on my LAN using...
2
by: PMB | last post by:
Thank you in advance for any and all assistance. I'm trying to input data from strings to a memo field. I would like to know how to check first to see if there is text there currently and if so...
2
by: donpro | last post by:
Hi, I have a varchar field in a MySQL database that contains a line of text like so: "This is a line if text" The double quotes are included in the database field. I cannot seem to...
1
George Lft
by: George Lft | last post by:
ok, first of all, i built my register page using dreamweaver tool which the codes haven been out of control. Now i'm thinking that turning over everything - by using this another set of codes. And...
1
by: gubbachchi | last post by:
Hi, For my project I have a "add" button, upon clicking it, it will take the user to next page where there will be a text box and list of data displayed below it which is fetched from mysql...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.