cs1h Posted October 16, 2007 Share Posted October 16, 2007 Hi, Does anyone know how to keep the formating of a textarea box (i.e. keep the lines and spaces between lines) when it gets put into a mysql table (the column set as text). All help will be much appriciated. Thanks Colin Quote Link to comment https://forums.phpfreaks.com/topic/73484-solved-help-formatting/ Share on other sites More sharing options...
Orio Posted October 16, 2007 Share Posted October 16, 2007 Try nl2br() Orio. Quote Link to comment https://forums.phpfreaks.com/topic/73484-solved-help-formatting/#findComment-370676 Share on other sites More sharing options...
cs1h Posted October 16, 2007 Author Share Posted October 16, 2007 Hi, Thanks for the reply, unfortunatly I don't know how to implement this. I'm pretty useless at php, is it possible for anyone to help me. My code so far is <?php // Remove spaces form conutry $targetb = $_POST['menuFilesDMA']; $targetb = str_replace(' ','_', $targetb); $targetc = $_POST['menuSubjectsDMA']; $targetc = str_replace(' ','_', $targetc); //This gets all the information from the form $name=$_POST['name']; $continent=($targetc); $country=($targetb); $town=$_POST['title2']; $type=$_POST['Catagory']; $Email=$_POST['Email']; $Title=$_POST['title']; $Abstract=$_POST['message']; //<<<<<-----This is the first text field $Article=$_POST['messagetwo']; //<<<<<-----This is the second text field // Connects to the Database mysql_connect("localhost", "xxx", "xxxd") or die(mysql_error()) ; mysql_select_db("real") or die(mysql_error()) ; //Writes the information to the database mysql_query($sql = "insert into `items` (`name`, `Continent`, `country`, `town`, `type`, `alltype`, `Email`, `Title`, `Abstract`, `Article`) values ('$name', '$continent', '$country', '$town', '$type', 'all', '$Email', '$Title', '$Abstract', '$Article')"); } ?> I have two text fields that need this fix. If anyone can help it will be very much appriciated. Thanks Colin Quote Link to comment https://forums.phpfreaks.com/topic/73484-solved-help-formatting/#findComment-370683 Share on other sites More sharing options...
Orio Posted October 16, 2007 Share Posted October 16, 2007 Before inserting the text into the database, apply nl2br() on the fields that came from text areas. This way, every newline will be converted into the "br" html tag. Orio. Quote Link to comment https://forums.phpfreaks.com/topic/73484-solved-help-formatting/#findComment-370736 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.