Jump to content

Recommended Posts

Below is my code. When I run this, the data for $row[coach] is one long parahraph unless I enter <br> or <p></p> in the database itself. Is there a way to breakup the paragraphs at run time instead of putting it in the database for each entry?

 

 

$db = mysql_connect("xxx", "xxx", "xxx");

 

mysql_select_db("xxx",$db);

 

$result = mysql_query("SELECT * FROM coaching where (title = '$TitleList')",$db);

 

if ($row = mysql_fetch_array($result)) {

 

do {

 

echo (" <table border=0 width=75% align=center>

<tr>

<td class=coachtitle>$row[title]</td>

</tr>

<tr>

<td> </td>

</tr>

<tr>

<td class=coach>nl2br($row[coach])</td>

</tr>

<tr>

<td class=author>$row[author]</td>

</tr>

<tr>

<td align=center><a href=/coaching.html>Back</a></td>

</tr>

 

");

 

} while ($myrow = mysql_fetch_array($result));

 

echo ("</table>");

Link to comment
https://forums.phpfreaks.com/topic/74902-line-spaces-in-mysql-php/
Share on other sites

This is the outcome of this:

 

nl2p(With whom can you share your joys and sorrows? Whom can you phone without having a reason? We have a range of emotions and sharing them doubles the good emotions and cuts the bad ones in half. Emotions always get better, therefore, through sharing. Identify the handful of people you can share your feelings with and put them on speed dial! )

 

What am I doing wrong?  This is what I used

 

<td class=coach>nl2p($row[coach])</td>

This is the outcome of this:

 

nl2p(With whom can you share your joys and sorrows? Whom can you phone without having a reason? We have a range of emotions and sharing them doubles the good emotions and cuts the bad ones in half. Emotions always get better, therefore, through sharing. Identify the handful of people you can share your feelings with and put them on speed dial! )

 

What am I doing wrong?  This is what I used

 

<td class=coach>nl2p($row[coach])</td>

 

Sorry about that didn't realize that was a custom function here's the code for that function.

#
function nl2p($text) {
return "<p>" . str_replace("

", "</p>
<p>", $text) . "</p>";
}

 

code was found here http://snipplr.com/view/987/nl2p/

OK I made the changes but it isn't working.  The data is inputted into the database via web panel like below and I need it to be presented this way when viewing

 

*************************************************************************************************

this is what it is doing

nl2p(With whom can you share your joys and sorrows? Whom can you phone without having a reason? We have a range of emotions and sharing them doubles the good emotions and cuts the bad ones in half. Emotions always get better, therefore, through sharing. Identify the handful of people you can share your feelings with and put them on speed dial! )

 

This is what I need it to look like

************************************************************************************************

With whom can you share your joys and sorrows?

 

Whom can you phone without having a reason?

 

We have a range of emotions and sharing them doubles the good emotions and cuts the bad ones in half.  Emotions always get better, therefore, through sharing.

 

Identify the handful of people you can share your feelings with and put them on speed dial!

 

OK I made the changes but it isn't working.  The data is inputted into the database via web panel like below and I need it to be presented this way when viewing

 

*************************************************************************************************

this is what it is doing

nl2p(With whom can you share your joys and sorrows? Whom can you phone without having a reason? We have a range of emotions and sharing them doubles the good emotions and cuts the bad ones in half. Emotions always get better, therefore, through sharing. Identify the handful of people you can share your feelings with and put them on speed dial! )

 

This is what I need it to look like

************************************************************************************************

With whom can you share your joys and sorrows?

 

Whom can you phone without having a reason?

 

We have a range of emotions and sharing them doubles the good emotions and cuts the bad ones in half.  Emotions always get better, therefore, through sharing.

 

Identify the handful of people you can share your feelings with and put them on speed dial!

 

 

 

Still Broken?

 

can you show the code you're using if you still need help on this?

 

This is why poorly formatted code is dangerous.

 

<?php
echo (" <table border=0 width=75% align=center>
<tr>
<td class=coachtitle>$row[title]</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td class=coach>nl2br($row[coach])</td>
</tr>
<tr>
<td class=author>$row[author]</td>
</tr>
<tr>
<td align=center><a href=/coaching.html>Back[/url]</td>
</tr>

");
?>

 

You are calling nl2br INSIDE A STRING.  You can't call a function inside a string.  Your first hint was having nl2p( in the output.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.