cactus Posted April 8, 2011 Share Posted April 8, 2011 Hi My problem is that text that is in my database are showing up next to each other in a line rather than on seperate lines, normally I would have just used <br> but as it's generated from my sql I don't know how to do it. <ul id="headlines"> <?php foreach ( $results['articles'] as $article ) { ?> <a href=".?action=viewArticle&articleId=<?php echo $article->id?>"><?php echo htmlspecialchars( $article->title )?></a> <?php } ?> </ul> Anyone have any idea? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/233069-line-breaks-on-mysql-generated-text/ Share on other sites More sharing options...
gristoi Posted April 8, 2011 Share Posted April 8, 2011 try wrapping li tags around the anchors <ul id="headlines"> <?php foreach ( $results['articles'] as $article ) { ?> <li><a href=".?action=viewArticle&articleId=<?php echo $article->id?>"><?php echo htmlspecialchars( $article->title )?></a></li> <?php } ?> </ul> Quote Link to comment https://forums.phpfreaks.com/topic/233069-line-breaks-on-mysql-generated-text/#findComment-1198639 Share on other sites More sharing options...
cactus Posted April 8, 2011 Author Share Posted April 8, 2011 That's going to give it bullet points though is there any other way of doing it than that? Thanks for replying Quote Link to comment https://forums.phpfreaks.com/topic/233069-line-breaks-on-mysql-generated-text/#findComment-1198644 Share on other sites More sharing options...
gristoi Posted April 8, 2011 Share Posted April 8, 2011 Just add a style to the ul tag and set the style for the li to #headlines li{ list-style:none;} That will give you no bullet points Quote Link to comment https://forums.phpfreaks.com/topic/233069-line-breaks-on-mysql-generated-text/#findComment-1198649 Share on other sites More sharing options...
barrycorrigan Posted April 8, 2011 Share Posted April 8, 2011 ul#healine { list-style-type:none; } ul#headline li { display:block; } Wrap it in an <li> tag and add a display block to make sure they go on separate lines Quote Link to comment https://forums.phpfreaks.com/topic/233069-line-breaks-on-mysql-generated-text/#findComment-1198651 Share on other sites More sharing options...
cactus Posted April 8, 2011 Author Share Posted April 8, 2011 Thank you that got rid of the bullet points is there anyway to make a bigger gap between the points like you would normally do with a <br> sign? There a bit too squished together for what I want. Thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/233069-line-breaks-on-mysql-generated-text/#findComment-1198653 Share on other sites More sharing options...
gristoi Posted April 8, 2011 Share Posted April 8, 2011 add padding or a margin to the list element Quote Link to comment https://forums.phpfreaks.com/topic/233069-line-breaks-on-mysql-generated-text/#findComment-1198658 Share on other sites More sharing options...
cactus Posted April 8, 2011 Author Share Posted April 8, 2011 Thank you Quote Link to comment https://forums.phpfreaks.com/topic/233069-line-breaks-on-mysql-generated-text/#findComment-1198660 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.