# Line breaks in PHP

**URL:** <https://discourse.softpress.com/t/line-breaks-in-php/24128>\
**Category:** Freeway\
**Created:** [April 23, 2018, 5:07pm UTC](https://discourse.softpress.com/t/line-breaks-in-php/24128 "2018-04-23T17:07:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rcacciato](https://discourse.softpress.com/user_avatar/discourse.softpress.com/rcacciato/32/55_2.png) [@rcacciato](https://discourse.softpress.com/u/rcacciato)\
**Post date:** [April 23, 2018, 5:07pm UTC](https://discourse.softpress.com/t/line-breaks-in-php/24128/1 "2018-04-23T17:07:20Z")

</div>

I am trying to create a database-driven newsroom in Freeway and am encountering two challenges:

1. I would like to style the text. I’ve placed php code in html markup items on a text box and formatted all the content in the text box as Helvetica 12 pt. but the text comes out unstyled.

2. I would like to have line breaks between the items but am unable to do that either by inserting   
, n or rn.

Here’s the markup code in 2 html markup items in the text box:

markup item 1:

\<?php $news = getAllByType('news',array('year'=\>'All','limit'=\>4)); ?\>

markup item 2:

\<?php showRows($news); echo "  
"; ?\>

Any suggestions? Thanks in advance.

Thanks,

[http://www.blue-iceberg.com/dbtest/pressroom.php](http://www.blue-iceberg.com/dbtest/pressroom.php)

* * *

freewaytalk mailing list  
email@hidden  
Update your subscriptions at:

> **[Information for existing FreewayTalk / Groups.io users](https://discourse.softpress.com/t/information-for-existing-freewaytalk-groups-io-users/24891)**
>
> The purpose of this topic is to provide information about the migration from FreewayTalk and Groups io to Discourse and the differences in Discourse, as well as a place to discuss the good or bad of the migration. For those previously subscribing...

---

<div class="post-metadata">

**Author:** ![david.ledger](https://discourse.softpress.com/user_avatar/discourse.softpress.com/david.ledger/32/53_2.png) [@david.ledger](https://discourse.softpress.com/u/david.ledger)\
**Post date:** [April 23, 2018, 8:24pm UTC](https://discourse.softpress.com/t/line-breaks-in-php/24128/2 "2018-04-23T20:24:29Z")

</div>

On 23 Apr 2018, at 18:07, Richard Cacciato wrote:

> I am trying to create a database-driven newsroom in Freeway and am  
> encountering two challenges:
> 
> 1. I would like to style the text. I’ve placed php code in html markup  
> items on a text box and formatted all the content in the text box as  
> Helvetica 12 pt. but the text comes out unstyled.
> 
> 2. I would like to have line breaks between the items but am unable to  
> do that either by inserting   
> , n or rn.
> 
> Here’s the markup code in 2 html markup items in the text box:
> 
> markup item 1:
> 
> \<?php $news = getAllByType('news',array('year'=\>'All','limit'=\>4)); ?\>
> 
> markup item 2:
> 
> \<?php showRows($news); echo "  
> "; ?\>
> 
> Any suggestions? Thanks in advance.

Presumably (what is, in effect)  
showRows(getAllByType(‘news’,array(‘year’=\>‘All’,‘limit’=\>4)))  
shows multiple rows of news. For the browser to put a line break  
in-between items you need to put a ‘  
’ between them. Have you  
tried putting a ‘  
’ on the end of each news item as it is stored  
in the database?

David

* * *

freewaytalk mailing list  
email@hidden  
Update your subscriptions at:  
[https://freewaytalk.softpress.com/person/options](https://freewaytalk.softpress.com/person/options)

---

<div class="post-metadata">

**Author:** ![rcacciato](https://discourse.softpress.com/user_avatar/discourse.softpress.com/rcacciato/32/55_2.png) [@rcacciato](https://discourse.softpress.com/u/rcacciato)\
**Post date:** [April 23, 2018, 8:26pm UTC](https://discourse.softpress.com/t/line-breaks-in-php/24128/3 "2018-04-23T20:26:15Z")

</div>

Unfortunately I can’t do that because the database powers something else.

* * *

freewaytalk mailing list  
email@hidden  
Update your subscriptions at:

> **[Information for existing FreewayTalk / Groups.io users](https://discourse.softpress.com/t/information-for-existing-freewaytalk-groups-io-users/24891)**
>
> The purpose of this topic is to provide information about the migration from FreewayTalk and Groups io to Discourse and the differences in Discourse, as well as a place to discuss the good or bad of the migration. For those previously subscribing...

---

<div class="post-metadata">

**Author:** ![david.ledger](https://discourse.softpress.com/user_avatar/discourse.softpress.com/david.ledger/32/53_2.png) [@david.ledger](https://discourse.softpress.com/u/david.ledger)\
**Post date:** [April 23, 2018, 8:32pm UTC](https://discourse.softpress.com/t/line-breaks-in-php/24128/4 "2018-04-23T20:32:07Z")

</div>

On 23 Apr 2018, at 21:26, Richard Cacciato wrote:

> Unfortunately I can’t do that because the database powers something  
> else.

In that case you need to find a way to get the news items on-by-one,  
loop through them, and include to output of a ‘  
’ within the  
loop after each one.

David

* * *

freewaytalk mailing list  
email@hidden  
Update your subscriptions at:  
[https://freewaytalk.softpress.com/person/options](https://freewaytalk.softpress.com/person/options)

---

<div class="post-metadata">

**Author:** ![waltd](https://discourse.softpress.com/user_avatar/discourse.softpress.com/waltd/32/2720_2.png) [@waltd](https://discourse.softpress.com/u/waltd)\
**Post date:** [April 24, 2018, 12:03am UTC](https://discourse.softpress.com/t/line-breaks-in-php/24128/5 "2018-04-24T00:03:58Z")

</div>

To style text that you are inserting from a markup item, try putting a space before and after the markup item, and then select the entire space/markup item/space sandwich as one line of text. With that selected, apply your style. Markup items all by themselves on a line do not get any styling applied to themselves.

As far as the loop goes, you’re going to need to break the function down to something that can show one line, rather than all rows. So imagine that you have such a function called `showLine($record)` you could do this:

```auto
<?php
foreach(getAllByType('news, array('year'=>'All','limit'=>4)) as $line){
?>

```

and then

```auto
[space with style]<?= showLine($line) ?>[shift-return (to make a line-break)]
[space with style]

```

followed by

```auto
<?php } ?>

```

Walter

> On Apr 23, 2018, at 1:07 PM, Richard Cacciato [email@hidden](mailto:email@hidden) wrote:
> 
> I am trying to create a database-driven newsroom in Freeway and am encountering two challenges:
> 
> 1. I would like to style the text. I’ve placed php code in html markup items on a text box and formatted all the content in the text box as Helvetica 12 pt. but the text comes out unstyled.
> 
> 2. I would like to have line breaks between the items but am unable to do that either by inserting   
> , n or rn.
> 
> Here’s the markup code in 2 html markup items in the text box:
> 
> markup item 1:
> 
> \<?php $news = getAllByType('news',array('year'=\>'All','limit'=\>4)); ?\>
> 
> markup item 2:
> 
> \<?php showRows($news); echo "  
> "; ?\>
> 
> Any suggestions? Thanks in advance.
> 
> Thanks,
> 
> [http://www.blue-iceberg.com/dbtest/pressroom.php](http://www.blue-iceberg.com/dbtest/pressroom.php)
> 
> * * *
> 
> freewaytalk mailing list  
> email@hidden  
> Update your subscriptions at:  
> [Information for existing FreewayTalk / Groups.io users - Site Feedback - Softpress Talk](https://freewaytalk.softpress.com/person/options)

* * *

freewaytalk mailing list  
email@hidden  
Update your subscriptions at:  
[https://freewaytalk.softpress.com/person/options](https://freewaytalk.softpress.com/person/options)
