affordit Posted August 14, 2009 Share Posted August 14, 2009 I have a form with a text box, to input directions for recipes they post and the problem I am having is when I insert the data into the database how do I include the carriage returns. Link to comment https://forums.phpfreaks.com/topic/170225-solved-including-carriage-returns/ Share on other sites More sharing options...
Mark Baker Posted August 14, 2009 Share Posted August 14, 2009 The carriage returns should be stored in the database already. However, when you retrieve from the database and display to a browser, the browser will ignore the carriage returns. You can replace the carriage returns with a <br /> that the browser won't ignore by using the nl2br() function on your retrieved text before echoing it to the browser Link to comment https://forums.phpfreaks.com/topic/170225-solved-including-carriage-returns/#findComment-897939 Share on other sites More sharing options...
affordit Posted August 14, 2009 Author Share Posted August 14, 2009 OK this is where I am processing the results, I only need to include the carriage returns for the directions. // PROCESS CONTENTS OF $RESULTS print "<table width='600' align='center' border='0'>"; $i = 0; while ($info = mysql_fetch_array($result)) { echo "<th colspan='2' align='center'><b>" . $info['recipe_name'] . "</b></th>"; echo "<tr><td width ='300' ALIGN='left'>" . $info['ingredient_1'] . "</td><td width='300' ALIGN='left'>" . $info['ingredient_2'] . "</td></tr><tr>"; echo "<td width ='300' ALIGN='left'>" . $info['ingredient_3'] . "</td><td width='300' ALIGN='left'>" . $info['ingredient_4'] . "</td></tr>"; echo "<tr><td width ='300' ALIGN='left'>" . $info['ingredient_5'] . "</td><td width='300' ALIGN='left'>" . $info['ingredient_6'] . "</td></tr><tr>"; echo "<td width ='300' ALIGN='left'>" . $info['ingredient_7'] . "</td><td width='300' ALIGN='left'>" . $info['ingredient_8'] . "</td></tr>"; echo "<tr><td width ='300' ALIGN='left'>" . $info['ingredient_9'] . "</td><td width='300' ALIGN='left'>" . $info['ingredient_10'] . "</td></tr><tr>"; echo "<td width ='300' ALIGN='left'>" . $info['ingredient_11'] . "</td><td width='300' ALIGN='left'>" . $info['ingredient_12'] . "</td></tr>"; echo "<tr><td width ='300' ALIGN='left'>" . $info['ingredient_13'] . "</td><td width='300' ALIGN='left'>" . $info['ingredient_14'] . "</td></tr><tr>"; echo "<td width ='300' ALIGN='left'>" . $info['ingredient_15'] . "</td><td width='300' ALIGN='left'>" . $info['ingredient_16'] . "</td></tr>"; echo "<tr><td width ='300' ALIGN='left'>" . $info['ingredient_17'] . "</td><td width='300' ALIGN='left'>" . $info['ingredient_18'] . "</td></tr><tr>"; echo "<td width ='300' ALIGN='left'>" . $info['ingredient_19'] . "</td><td width='300' ALIGN='left'>" . $info['ingredient_20'] . "</td></tr>"; echo "<tr><td width ='300' ALIGN='left'>" . $info['ingredient_21'] . "</td><td width='300' ALIGN='left'>" . $info['ingredient_22'] . "</td></tr><tr>"; echo "<td width ='300' ALIGN='left'>" . $info['ingredient_23'] . "</td><td width='300' ALIGN='left'>" . $info['ingredient_24'] . "</td></tr>"; echo "<tr><td width ='300' ALIGN='left'>" . $info['ingredient_25'] . "</td><td width='300' ALIGN='left'>" . $info['ingredient_26'] . "</td></tr><tr>"; echo "<td width ='300' ALIGN='left'>" . $info['ingredient_27'] . "</td><td width='300' ALIGN='left'>" . $info['ingredient_28'] . "</td></tr>"; echo "<tr><td width ='300' ALIGN='left'>" . $info['ingredient_29'] . "</td><td width='300' ALIGN='left'>" . $info['ingredient_30'] . "</td></tr><tr>"; echo "<td width ='300' ALIGN='left'>" . $info['ingredient_31'] . "</td><td width='300' ALIGN='left'>" . $info['ingredient_32'] . "</td></tr>"; echo "<tr><td width ='300' ALIGN='left'>" . $info['ingredient_33'] . "</td><td width='300' ALIGN='left'>" . $info['ingredient_34'] . "</td></tr><tr>"; echo "<td width ='300' ALIGN='left'>" . $info['ingredient_35'] . "</td><td width='300' ALIGN='left'>" . $info['ingredient_36'] . "</td></tr><tr>"; echo "<td colspan='2' ALIGN='justify'>" . $info['directions'] . "</td></tr>"; echo"<BR />"; $i++; if($i % 1 == 0){ echo "</table>"; Where does the nl2br() come in, only at $info['directions'] ? Link to comment https://forums.phpfreaks.com/topic/170225-solved-including-carriage-returns/#findComment-897945 Share on other sites More sharing options...
affordit Posted August 14, 2009 Author Share Posted August 14, 2009 Thanks Mark that was much easier than I thought, works like a charm. Link to comment https://forums.phpfreaks.com/topic/170225-solved-including-carriage-returns/#findComment-897946 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.