Jump to content

[SOLVED] Database Display


maliary

Recommended Posts

 

 

Hi guys,

 

I've the following information that I retrive from the database :

 

1.The little fox jumped over a green hedge.2.The hare ate fish.3.The little fox jumped over a green hedge

4.Alligator jumped  a green hedge.5.The little fox jumped over a green hedge

 

How would I display it thus :

1.The little fox jumped over a green hedge

2.The hare ate fish

3.The little fox jumped over a green hedge

4.Alligator jumped  a green hedge.

5.The little fox jumped over a green hedge

 

 

 

Link to comment
Share on other sites

<?php
$string = "1.The little fox jumped over a green hedge.2.The hare ate fish.3.The little fox jumped over a green hedge4.Alligator jumped  a green hedge.5.The little fox jumped over a green hedge";
print preg_replace("([2-100])","<br>\\0",$string);
?>

 

Does this help?

Link to comment
Share on other sites

or

<?php
$string = "1.The little fox jumped over a green hedge.2.The hare ate fish.3.The little fox jumped over a green hedge4.Alligator jumped  a green hedge.5.The little fox jumped over a green hedge";
print $result = preg_replace('/(?<=.+)(\d\.)/i', "\r\n\$1", $string);
?>

Link to comment
Share on other sites

Ok,

 

        The notes field in the database is of datatype text.

 

          $depts = $db->Execute("SELECT * FROM test_find WHERE job_id='$batch_nr'");               

          while($row= $depts->FetchRow()){

 

          $notes = $row['notes'];       

            }

 

    <td><?php echo $notes; ?></td>

  This gives the following out put :

 

1.The little fox jumped over a green hedge.2.The hare ate fish.3.The little fox jumped over a green hedge

4.Alligator jumped  a green hedge.5.The little fox jumped over a green hedge

 

 

Link to comment
Share on other sites

try

<?php
          $depts = $db->Execute("SELECT * FROM test_find WHERE job_id='$batch_nr'");                 
          while($row= $depts->FetchRow()){

          $notes = $row['notes']."<br>";         
             }
?>
    <td><?php echo $notes; ?></td> 

Link to comment
Share on other sites

This should be fine..

 

define "jumbled up"..

 

try

<?php
          $depts = $db->Execute("SELECT * FROM test_find WHERE job_id='$batch_nr'");                 
          while($row= $depts->FetchRow()){

          $notes = $row['notes']."<br>";         
             }
?>
    <td><?php echo $notes; ?></td> 

 

 

maybe a more complete code!?

 

ie the full table setup (HTML table)

Link to comment
Share on other sites

 

 

1. Yes, I want to break up the out put that way as in:

 

1.One

2.Two

3.Three

 

I've realised that, If I out put the data from the database in a text area, if formats itself fine,Without using any functions. What's wrong with the <td></td> tags then?

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.