DarkPrince2005 Posted August 8, 2008 Share Posted August 8, 2008 I've got a field in my mysql database that stores a product discription listin all its features, but when i echo it it returns it all in one line instead of each other, but when i echo it in a textarea it displays correctly. How can I fix this? <?php mysql_connect("localhost","root",""); mysql_select_db("products"); $sql=mysql_query("select * from tbl_product where product_id like '$_POST[product_id]'"); while ($row=mysql_fetch_array($sql)){ echo "$row[description]"; }?> Quote Link to comment https://forums.phpfreaks.com/topic/118772-solved-list-echo/ Share on other sites More sharing options...
alin19 Posted August 8, 2008 Share Posted August 8, 2008 try <?php mysql_connect("localhost","root",""); mysql_select_db("products"); $sql=mysql_query("select * from tbl_product where product_id like '$_POST[product_id]'"); while ($row=mysql_fetch_array($sql)){ echo "$row[description]"."\n"; }?> Quote Link to comment https://forums.phpfreaks.com/topic/118772-solved-list-echo/#findComment-611522 Share on other sites More sharing options...
wildteen88 Posted August 8, 2008 Share Posted August 8, 2008 try <?php mysql_connect("localhost","root",""); mysql_select_db("products"); $sql=mysql_query("select * from tbl_product where product_id like '$_POST[product_id]'"); while ($row=mysql_fetch_array($sql)){ echo "$row[description]"."\n"; }?> New lines (\r\n \n or \r) are not displayed, you need to use the <br /> tag to display a new line. echo "$row[description]<br />\n"; Quote Link to comment https://forums.phpfreaks.com/topic/118772-solved-list-echo/#findComment-611527 Share on other sites More sharing options...
DarkPrince2005 Posted August 8, 2008 Author Share Posted August 8, 2008 nope, that doesn't work Quote Link to comment https://forums.phpfreaks.com/topic/118772-solved-list-echo/#findComment-611529 Share on other sites More sharing options...
alin19 Posted August 8, 2008 Share Posted August 8, 2008 try <?php mysql_connect("localhost","root",""); mysql_select_db("products"); $sql=mysql_query("select * from tbl_product where product_id like '$_POST[product_id]'"); while ($row=mysql_fetch_array($sql)){ echo "$row[description]"."\n"; }?> New lines (\r\n \n or \r) are not displayed, you need to use the <br /> tag to display a new line. echo "$row[description]<br />\n"; yes you're right i use cli and confuse them Quote Link to comment https://forums.phpfreaks.com/topic/118772-solved-list-echo/#findComment-611530 Share on other sites More sharing options...
DarkPrince2005 Posted August 8, 2008 Author Share Posted August 8, 2008 the value in that field are: eg. Celeron 1.5GHz, 512MB RAM, LCD Monitor, etc. I want it to be displayed: Celeron 1.5GHz, 512MB RAM, LCD Monitor, instead of Celeron 1.5GHz, 512MB RAM, LCD Monitor Quote Link to comment https://forums.phpfreaks.com/topic/118772-solved-list-echo/#findComment-611532 Share on other sites More sharing options...
alin19 Posted August 8, 2008 Share Posted August 8, 2008 <?php mysql_connect("localhost","root",""); mysql_select_db("products"); $sql=mysql_query("select * from tbl_product where product_id like '$_POST[product_id]'"); while ($row=mysql_fetch_array($sql)){ $x=explode(",",$row[description]); foreach ($x as $Y) { echo $y." </br>"; } }?> Quote Link to comment https://forums.phpfreaks.com/topic/118772-solved-list-echo/#findComment-611535 Share on other sites More sharing options...
DarkPrince2005 Posted August 8, 2008 Author Share Posted August 8, 2008 thanx alin19, that works perfectly Quote Link to comment https://forums.phpfreaks.com/topic/118772-solved-list-echo/#findComment-611536 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.