Jump to content

[SOLVED] Including carriage returns


affordit

Recommended Posts

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

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'] ?

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.