Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old November 26th, 2003, 05:06 PM
mdhall mdhall is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 158 mdhall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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.

Reply With Quote
  #2  
Old November 26th, 2003, 05:12 PM
zackcoburn zackcoburn is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 184 zackcoburn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 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?

Reply With Quote
  #3  
Old November 26th, 2003, 05:25 PM
mdhall mdhall is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 158 mdhall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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?

Reply With Quote
  #4  
Old November 26th, 2003, 06:00 PM
postalcow postalcow is offline
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Ford CIty, PA USA
Posts: 1,267 postalcow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via Yahoo to postalcow
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

Reply With Quote
  #5  
Old November 26th, 2003, 06:13 PM
mdhall mdhall is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 158 mdhall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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.

Reply With Quote
  #6  
Old November 26th, 2003, 07:16 PM
postalcow postalcow is offline
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Ford CIty, PA USA
Posts: 1,267 postalcow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via Yahoo to postalcow
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);

Reply With Quote
  #7  
Old November 26th, 2003, 07:43 PM
mdhall mdhall is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 158 mdhall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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>

Reply With Quote
  #8  
Old November 26th, 2003, 08:59 PM
brut brut is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 367 brut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 30 sec
Reputation Power: 2
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?

Reply With Quote
  #9  
Old November 26th, 2003, 11:27 PM
mdhall mdhall is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 158 mdhall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Line break display not working

I tried that also...no luck.

Reply With Quote
  #10  
Old November 27th, 2003, 05:29 PM
-vertigo- -vertigo- is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Louth, Lincolnshire
Posts: 314 -vertigo- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 24 sec
Reputation Power: 2
RE: Line break display not working

Help me out here, what does the 'wrap=virtual' do?

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Line break display not working


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway