|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Line break display not working
I've tried these to show line breaks in a display query. The data was added from text areas to a db.
$replText=str_replace("n","<br>",$directions); nl2br($directions); Neither one is showing the carriage returns from the textarea submittal. |
|
#2
|
|||
|
|||
|
RE: Line break display not working
nl2br() should change all n line breaks to <br /> HTML line breaks. I can't see how it wouldn't be working. What does the input look like, and what does the output look like, exactly?
|
|
#3
|
|||
|
|||
|
RE: Line break display not working
The input comes from a standard form textarea, and is input to the db with an insert query, as usual.
From the form... Directions:<br> <textarea name=directions cols=30 rows=6 wrap=virtual></textarea> The input query... $query = "INSERT INTO recipes VALUES ('','$recipe_name','$recipe_category','$recipe_des c','$prep_time','$cook_time','$servings', '$ingredients','$directions','$submit_by')"; And the codes from the first post I placed are in the page that displays the db info. I'm also using _POST from the form to the input query page...would this have anything to do with it? |
|
#4
|
|||
|
|||
|
RE: Line break display not working
Ok, then use ereg_replace() and 13 for /n
<? ereg_replace(13,"<br>",$recipe); ?> That'll work for you |
|
#5
|
|||
|
|||
|
RE: Line break display not working
Where, exactly, is this supposed to go in the code? Now all I'm getting is a blank screen when I use this.
|
|
#6
|
|||
|
|||
|
RE: Line break display not working
Sorry replace your line that says;
$replText=str_replace("n","<br>",$directions); With This Line $replText = ereg_replace("13","<br>",$directions); |
|
#7
|
|||
|
|||
|
RE: Line break display not working
Sorry...still not working. Heres the results page. It takes the row id from a search page anchor link and displays all the info from the row, and has a link to a page for comments to be added on this row's topic, plus it included the comments. I'm not sure if I'm using the best or most efficient way to display the results, but it works...except for the line breaks.
[highlight=php] <html><head><title>cookbook</title></head> <body bgcolor=#cfcedf><center> <form action=search.php method=post> <table width=700 border=0 cellpadding=4 cellspacing=0> <tr> <td align=center valign=top colspan=3> <?php include("top.php"); ?> </td></tr> <tr> <td width=150 valign=top align=left> <?php include("left.php"); ?> </td> <td width=400 valign=top> <? $id=$_GET['id']; $replText = ereg_replace("13","<br>",$ingredients); $replText = ereg_replace("13","<br>",$directions); include("dbinfo.inc.php"); $dbh=mysql_connect ("localhost", "$username", "$password") or die ('I cannot connect to the database because: '. mysql_error()); mysql_select_db ("$database"); $query=("SELECT * FROM recipes WHERE id='$id'"); $result = mysql_query($query); $num=mysql_num_rows($result); $i = 0; echo "<table width=380 border=0>"; while ($i < $num): $id=mysql_result($result,$i,"id"); $recipe_name=mysql_result($result,$i,"recipe_name"); $prep_time=mysql_result($result,$i,"prep_time"); $cook_time=mysql_result($result,$i,"cook_time"); $servings=mysql_result($result,$i,"servings"); $ingredients=mysql_result($result,$i,"ingredients"); $directions=mysql_result($result,$i,"directions"); $submit_by=mysql_result($result,$i,"submit_by"); echo "<tr><td width=380 valign=top colspan=2><br> <font size=2 face=verdana, times color=black><b> <div align=center> $recipe_name</div></b><br> Submitted by $submit_by<br> Prep Time: $prep_time<br> Cook Time: $cook_time<br> Appx Servings: $servings<br> Ingredients:<br>$ingredients<br> Directions:<br>$directions<p> <div align=center><input type=button value="Print Recipe" onClick="print()"> <div align=center><a href="addcomment.php?id=$id">Add a comment on this recipe</a><br /></div> </font></td></tr>"; $i++; endwhile; $query=("SELECT * FROM comments WHERE recipes_id='$id'"); $result = mysql_query($query); $num=mysql_num_rows($result); $i = 0; echo "<table width=380 border=0><tr><td valign=top align=center colspan=2> <font face=verdana, arial size=2 color=black><b> $num comments for this recipe.</b></font></td></tr>"; while ($i < $num): $recipes_id=mysql_result($result,$i,"recipes_id"); $comments=mysql_result($result,$i,"comments"); echo "<tr><td width=380 valign=top colspan=2> <font size=2 face=verdana, times color=black> $comments<p> </font> </td></tr>"; $i++; endwhile; ?> </table> </td> <td width=150 valign=top align=center> <?php include("right.php"); ?> </td> </tr> </table> </html> |
|
#8
|
|||
|
|||
|
RE: Line break display not working
I just glanced quickly, but shouldn't whatever replacement method you choose go toward the bottom, after you've assigned values to $directions and $ingredients?
|
|
#9
|
|||
|
|||
|
RE: Line break display not working
I tried that also...no luck.
|
|
#10
|
|||
|
|||
|
RE: Line break display not working
Help me out here, what does the 'wrap=virtual' do?
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > Line break display not working |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|