Jump to content

[SOLVED] Retain a carriage return from a text box.


jeff5656

Recommended Posts

I have a text box. If a user hits carriage return I want to retain that and store that in the database.  However, it all gets displayed as one line:

 

here's the form:

 

<th><div align="left">Active Problem List</div></th>
      <td><textarea name="problist" id="problist" cols="45" rows="3">1.
2.</textarea></td>

 

Here is me inserting it into the database:

$problist = $_POST['problist'];
.....

$query = "INSERT INTO icu (id_incr, rm_loc, pod, patient, mrn, age, race, gender, rcf_date, rcf_date2, dx, meds, pmhx, problist, problist_date, anticipate, anticipate_date, antic2, antic3, antic4, antic2_date, antic3_date, antic4_date, todo, todo2, todo3, todo4, todo_date, todo2_date, todo3_date, todo4_date, comments, comments_date, code, allergy, signoff_status)

VALUES('$id_incr','$rm_loc', '$pod', '$patient', '$mrn', '$age', '$race', '$gender', '$rcf_date', '$rcf_date2', '$dx', '$meds','$pmhx', '$problist', '$problist_date', '$anticipate', '$anticipate_date', '$antic2', '$antic3', '$antic4', '$antic2_date', '$antic3_date', '$antic4_date','$todo', '$todo2', '$todo3', '$todo4','$todo_date', '$todo2_date', '$todo3_date', '$todo4_date',  '$comments', '$comments_date','$code', '$allergy','a')";

 

Here is the display the reads as one line (but does word wrap)

 <td bgcolor="#FFFFFF" valign="bottom">
  <?php echo $row['problist'];
  
  echo "<p align='right' style='font-family:verdana;font-size:65%;color:red'>";
  echo "Updated  ";
  echo date("m/d/Y @ H:i", strtotime($row['problist_date']));
  echo "</p>";

www.php.net/nl2br

 

Chances are it is kept, just html requires it to be converted to a <br> tag to display it.

 

Before echoing out the item you want to display the break try wrapping it in the nl2br function.

 

Hope that helps.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.