essjay_d12 Posted March 13, 2006 Share Posted March 13, 2006 I am pulling content out of a database using the same command in PHP as MySQL.This is the following code entered into, F_REVIEW varchar (10000), field.......[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]'Hot-shot photographer L. B. Jeffries - or "Jeff", as he's known to his chums - is at a bit of a loose end. You see he's stuck in a wheelchair, having broken a leg in a car accident whilst working on a Grand Prix circuit (perhaps a bit of a touchy subject considering Grace Kelly's in the cast). So, passing the time in the only way he can think of, he's started spying on the neighbours through his big ol' telephoto lens.The trouble is, Jeff's hobby becomes more like an obsession when he starts to suspect the silver-haired bloke across the street (Raymond 'Perry Mason' Burr) of murdering his wife. Is his idle mind playing tricks on him, or is poor Mrs Thorwald really buried underneath the family flowerbed?'[/quote]// Then main thing here is that it has been split into 2 paragraphs....Now, using the following command in MySQL 'Select F_REVIEW from films WHERE ID_NO=2;' it produces it in two paragraphs but using the same command in php produces it in one paragraph only.The data was inserted using an insert form through php using a <textarea name="F_Review"></textarea> tag.the following code is the php code used to get the film review.[code]<?php//open connection$conn = mysql_connect("localhost", "admin", "adm1n");mysql_select_db("project",$conn);$query =("SELECT F_REVIEW FROM films WHERE ID_NO=2");$result = mysql_query($query);while ($row = mysql_fetch_assoc($result)) { echo $row['F_REVIEW'];}?>[/code]How can I get php to recognise or produce it in two paragraphs?Thanks D Quote Link to comment Share on other sites More sharing options...
obsidian Posted March 13, 2006 Share Posted March 13, 2006 [!--quoteo(post=354476:date=Mar 13 2006, 07:38 AM:name=Essjay_d12)--][div class=\'quotetop\']QUOTE(Essjay_d12 @ Mar 13 2006, 07:38 AM) [snapback]354476[/snapback][/div][div class=\'quotemain\'][!--quotec--]How can I get php to recognise or produce it in two paragraphs?Thanks D[/quote]just remember that when you echo something in PHP, you're actually producing markup, and thus, you have to create recognizable line breaks (ie, <br /> tags). so, check out the nl2br() function that translates the newline characters in a code block into <br /> tags.try this:[code]echo nl2br($row['F_REVIEW']);[/code] Quote Link to comment Share on other sites More sharing options...
XenoPhage Posted March 13, 2006 Share Posted March 13, 2006 [!--quoteo(post=354476:date=Mar 13 2006, 07:38 AM:name=Essjay_d12)--][div class=\'quotetop\']QUOTE(Essjay_d12 @ Mar 13 2006, 07:38 AM) [snapback]354476[/snapback][/div][div class=\'quotemain\'][!--quotec--]The data was inserted using an insert form through php using a <textarea name="F_Review"></textarea> tag.How can I get php to recognise or produce it in two paragraphs?[/quote]HTML will ignore \n (linefeed) ... So you need to convert those to <br /> .. Try using nl2br() before displaying the info from the database.Or, it may be possible that when you stored the data that was submitted, something you did stripped the line feeds.. Can't tell that unless you post that part of the code. Quote Link to comment Share on other sites More sharing options...
shocker-z Posted March 13, 2006 Share Posted March 13, 2006 echo str_replace("\n",'<Br>',$row['F_REVIEW']);use that instead ofecho $row['F_REVIEW'];that will replace all occurances of \n (which is new line/return charactor) with <br> Quote Link to comment Share on other sites More sharing options...
essjay_d12 Posted March 13, 2006 Author Share Posted March 13, 2006 echo nl2br($row['F_REVIEW']);That worked, thank you very muchCheers D Quote Link to comment 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.