RE: [PHP] html formatting in mysql post
thanks for your responses, so i understand that this code is using an array, however i havn't really used arrays as i am a novice php coder. Should this code be used on the php code for inserting the data into the MySQL table or is it used when retrieving the data using the select function? ?php // $row = /* Database row grabbed elsewhere in your code. */''; if (is_array($row)) { foreach ($row as $r) { echo nl2br($row).PHP_EOL; } } else { echo nl2br($row).PHP_EOL; } ? your help is appreciated. From: danbr...@php.net Date: Fri, 6 May 2011 23:04:44 -0400 To: hansen.r...@live.com.au CC: php-general@lists.php.net Subject: Re: [PHP] html formatting in mysql post On Fri, May 6, 2011 at 22:52, Ross Hansen wrote: Hey Guys, I am using a form to post information to a MySQL table which is then echo(ing) back out to a web page. it will sort of be like facebook where you can post messages and stuff on peoples walls. The only issue is at the moment i can get the formatting to stay. When i echo the table out from mysql it all gets displayed on one line rather than seeing my new lines which i typed in the text box. I do know that this is a HTML error as it was never given the format tags when the content was posted in the table. I have seen something about NL2BR and also something about strip slashes but i am not sure how to incorporate them into my post. Could someone please advise? Well, let's start with an easy question: have you *tried* them? // $row = /* Database row grabbed elsewhere in your code. */''; if (is_array($row)) { foreach ($row as $r) { echo nl2br($row).PHP_EOL; } } else { echo nl2br($row).PHP_EOL; } ? Error-handling and the remainder of checking is up to you. -- Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] html formatting in mysql post
On Sat, 2011-05-07 at 16:01 +0800, Ross Hansen wrote: thanks for your responses, so i understand that this code is using an array, however i havn't really used arrays as i am a novice php coder. Should this code be used on the php code for inserting the data into the MySQL table or is it used when retrieving the data using the select function? ?php // $row = /* Database row grabbed elsewhere in your code. */''; if (is_array($row)) { foreach ($row as $r) { echo nl2br($row).PHP_EOL; } } else { echo nl2br($row).PHP_EOL; } ? your help is appreciated. From: danbr...@php.net Date: Fri, 6 May 2011 23:04:44 -0400 To: hansen.r...@live.com.au CC: php-general@lists.php.net Subject: Re: [PHP] html formatting in mysql post On Fri, May 6, 2011 at 22:52, Ross Hansen wrote: Hey Guys, I am using a form to post information to a MySQL table which is then echo(ing) back out to a web page. it will sort of be like facebook where you can post messages and stuff on peoples walls. The only issue is at the moment i can get the formatting to stay. When i echo the table out from mysql it all gets displayed on one line rather than seeing my new lines which i typed in the text box. I do know that this is a HTML error as it was never given the format tags when the content was posted in the table. I have seen something about NL2BR and also something about strip slashes but i am not sure how to incorporate them into my post. Could someone please advise? Well, let's start with an easy question: have you *tried* them? // $row = /* Database row grabbed elsewhere in your code. */''; if (is_array($row)) { foreach ($row as $r) { echo nl2br($row).PHP_EOL; } } else { echo nl2br($row).PHP_EOL; } ? Error-handling and the remainder of checking is up to you. -- Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I think it would be well worth getting a book out on PHP or reading through the various online tutorials and the PHP manual. It will explain basic things like connecting to the database, using functions, echoing content to the screen, etc. -- Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] html formatting in mysql post
After doing further reading on google i have managed to get this working using the nl2br php command. if anyone else wants to know how i did this. almost the same as what was mentioned in this thread however my rows were being displayed using while command. echo nl2br($row['colname']); Thanks again for your assistance. From: a...@ashleysheridan.co.uk To: hansen.r...@live.com.au CC: php-general@lists.php.net Date: Sat, 7 May 2011 10:32:11 +0100 Subject: RE: [PHP] html formatting in mysql post On Sat, 2011-05-07 at 16:01 +0800, Ross Hansen wrote: thanks for your responses, so i understand that this code is using an array, however i havn't really used arrays as i am a novice php coder. Should this code be used on the php code for inserting the data into the MySQL table or is it used when retrieving the data using the select function? // $row = /* Database row grabbed elsewhere in your code. */''; if (is_array($row)) { foreach ($row as $r) { echo nl2br($row).PHP_EOL; } } else { echo nl2br($row).PHP_EOL; } ? your help is appreciated. From: danbr...@php.net Date: Fri, 6 May 2011 23:04:44 -0400 To: hansen.r...@live.com.au CC: php-general@lists.php.net Subject: Re: [PHP] html formatting in mysql post On Fri, May 6, 2011 at 22:52, Ross Hansen wrote: Hey Guys, I am using a form to post information to a MySQL table which is then echo(ing) back out to a web page. it will sort of be like facebook where you can post messages and stuff on peoples walls. The only issue is at the moment i can get the formatting to stay. When i echo the table out from mysql it all gets displayed on one line rather than seeing my new lines which i typed in the text box. I do know that this is a HTML error as it was never given the format tags when the content was posted in the table. I have seen something about NL2BR and also something about strip slashes but i am not sure how to incorporate them into my post. Could someone please advise? Well, let's start with an easy question: have you *tried* them? // $row = /* Database row grabbed elsewhere in your code. */''; if (is_array($row)) { foreach ($row as $r) { echo nl2br($row).PHP_EOL; } } else { echo nl2br($row).PHP_EOL; } ? Error-handling and the remainder of checking is up to you. -- Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I think it would be well worth getting a book out on PHP or reading through the various online tutorials and the PHP manual. It will explain basic things like connecting to the database, using functions, echoing content to the screen, etc. -- Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] html formatting in mysql post
Hey Guys, I am using a form to post information to a MySQL table which is then echo(ing) back out to a web page. it will sort of be like facebook where you can post messages and stuff on peoples walls. The only issue is at the moment i can get the formatting to stay. When i echo the table out from mysql it all gets displayed on one line rather than seeing my new lines which i typed in the text box. I do know that this is a HTML error as it was never given the format tags when the content was posted in the table. I have seen something about NL2BR and also something about strip slashes but i am not sure how to incorporate them into my post. Could someone please advise?
Re: [PHP] html formatting in mysql post
On Fri, May 6, 2011 at 22:52, Ross Hansen hansen.r...@live.com.au wrote: Hey Guys, I am using a form to post information to a MySQL table which is then echo(ing) back out to a web page. it will sort of be like facebook where you can post messages and stuff on peoples walls. The only issue is at the moment i can get the formatting to stay. When i echo the table out from mysql it all gets displayed on one line rather than seeing my new lines which i typed in the text box. I do know that this is a HTML error as it was never given the format tags when the content was posted in the table. I have seen something about NL2BR and also something about strip slashes but i am not sure how to incorporate them into my post. Could someone please advise? Well, let's start with an easy question: have you *tried* them? ?php // $row = /* Database row grabbed elsewhere in your code. */''; if (is_array($row)) { foreach ($row as $r) { echo nl2br($row).PHP_EOL; } } else { echo nl2br($row).PHP_EOL; } ? Error-handling and the remainder of checking is up to you. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php