0

I have a field called "system" in my database which looks like this

system field;

registration    //This field is part of a table called "system_owner" 
elearning       //all three value is in one string which each contains "\n"
payment

When I removed the "elearning" with this SQL statement;

$SQL = "UPDATE system_owner SET system=REPLACE(system,'elearning','')

The system field became like this;

registration

payment

My problem is how do I remove the empty space between "registration" and "payment"? What SQL statement should I use?

The output of the field that I want

registration
payment
1
  • This is a common problem for tables not adhering to the first normal form. It's usually hard to work with such fields in SQL so a common way is to do all the work in the application code instead. Here's an example on how to do it in PHP: stackoverflow.com/a/11079123/238978 Commented Jun 20, 2012 at 4:47

1 Answer 1

4

What if you try:

$SQL = "UPDATE system_owner SET system=REPLACE(system,'elearning\n','')
Sign up to request clarification or add additional context in comments.

4 Comments

It works but when I try to display it into a textarea box, there's still empty space between them. I don't know why but in the database, the data looks exactly what I wanted. What went wrong?
Can you show how you are displaying in textarea? May be its something that you are doing while displaying in the textarea.
<textarea name="rSistem" id="own" rows="6" cols="30" style="resize: none;" >'.$system.'</textarea>
Sorry if I'm asking too much but can you try it out? save something like mine from a textarea into database and edit the data. Then display it again into the textarea. Maybe you know what went wrong that way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.