Jump to content

[SOLVED] How do I break up using nl2br?


westmatrix99

Recommended Posts

Please can you explain what you're trying to do.

 

The nl2br function doesn't add tables, it merely replaces \n with \n<br />.

 

Which functions you need would depend on what $row_rsabout['about'] is: is it a string? An array? An object? xml?

Link to comment
Share on other sites

What is contained in $row_rsabout['about']?  What data?  Are there \n's or < br />'s?  Well, whatever, you can use explode like the guy above said to break a line up into array values by using key strings, for example, this string:

 

$string = "Hello world, I am the coolest program ever!";

 

if applied into the explode function like so:

 

$array = explode(" ", $string);

 

Would look like this upon doing print_r($array):

 

Array
(
   [0] => Hello
   [1] => world,
   [2] => I
   [3] => am
   [4] => the
   [5] => coolest
   [6] => program
   [7] => ever!
)

 

It would break the string up by spaces.

 

Make sense?

Link to comment
Share on other sites

I have a table called about with:

ID => INT

about => TEXT

 

I need the record <?php echo ($row_rsabout['about']); ?> to be broken up in different tables as I have on my  page.

So if I have three tables then the record must span across all three.

 

Hope that makes more sense?

Link to comment
Share on other sites

Ok each table is broken up already using the normal or standard HMTL table option

The data is in each table but not from the database.

I would need the data from the database table to be broken up into the different tables.

The home page is fine, it's the others that I will have this problem with.

 

Table1

Data from the same record

Table2

rest of the data from the same record

My option that will work but is irritating:
The other option is to have the administration panel have the different textboxes for each table of data.
That way the records would be seperated easier

Link to comment
Share on other sites

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>TEST BREAK UP</title>
</head>
<body>
<p>TABLE1</p>
<table width="300" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <td><?php echo nl2br($row_rsabout['AboutUs']); ?></td>
  </tr>
  <tr>
    <td> </td>
  </tr>
</table>
<p>TABLE2</p>
<table width="300" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <td><?php echo nl2br($row_rsabout['AboutUs']); ?></td>
  </tr>
  <tr>
    <td> </td>
  </tr>
</table>
<p>TABLE3</p>
<table width="300" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <td><?php echo nl2br($row_rsabout['AboutUs']); ?></td>
  </tr>
  <tr>
    <td> </td>
  </tr>
</table>
<p>THE END</p>
</body>
</html>

Link to comment
Share on other sites

Oh you want to create the HTML for that page from the database. How is the $row_rsabout['about'] created what data does it hold. It might be helpful if you could post more code.

 

The record "about" just holds demo data.

mysql_select_db($database_cnaida, $cnaida);
$query_rsabout = "SELECT * FROM tblabout";
$rsabout = mysql_query($query_rsabout, $cnaida) or die(mysql_error());
$row_rsabout = mysql_fetch_assoc($rsabout);
$totalRows_rsabout = mysql_num_rows($rsabout);

Link to comment
Share on other sites

Oh you want to create the HTML for that page from the database. How is the $row_rsabout['about'] created what data does it hold. It might be helpful if you could post more code.

 

The record "about" just holds demo data.

By code I ment the code you currently have for pulling AboutUs outof the database. You'll need to use tihs code:

<table width="300" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <td><?php echo nl2br($row_rsabout['AboutUs']); ?></td>
  </tr>
  <tr>
    <td> </td>
  </tr>
</table>

Within a while loop when you have ran your sql query.

Link to comment
Share on other sites

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.