I've got a mysql database that's storing news article information. I've got fields for 'headline' 'date' 'news_source' and 'article'. The article field is set to the 'text' data type.
I don't think this is the ideal way to store this info, but as there will be no more than about 15 rows in the table at any one time, and each article is only about 4 paragraphs long, I think it will be OK.
The problem I'm having is that I've set up a script to edit news items that have already been inserted into the database. After calling the row from the database a html form is written out, and then I've used some php generated javascript to populate the fields with the info from the Database:
Line breaks are what's causing the problem. For the javascript to work it needs to recieve the text in one long line. I thought nl2br() would sort it out, but it seems that all this does is add a <br> to the text at the same point as the newline rather than replacing it.
Is there anyway that I can get formatted text that contains newlines to output without them?
I don't think this is the ideal way to store this info, but as there will be no more than about 15 rows in the table at any one time, and each article is only about 4 paragraphs long, I think it will be OK.
The problem I'm having is that I've set up a script to edit news items that have already been inserted into the database. After calling the row from the database a html form is written out, and then I've used some php generated javascript to populate the fields with the info from the Database:
Code:
echo "document.onload = document.formname.fieldname.value ='".addslashes($row['article'])."';";
Is there anyway that I can get formatted text that contains newlines to output without them?