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]"; }?> 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"; }?> 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"; 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 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 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 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>"; } }?> 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 Link to comment https://forums.phpfreaks.com/topic/118772-solved-list-echo/#findComment-611536 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.