hansenb88 Posted January 12, 2007 Share Posted January 12, 2007 Hi, I am quite new to writing php, and have what I feel is a very basic problem. I have a chunk of code that connects to a mysql database and retrieves an array from it based on user input. Everything works fine until displaying the output, when every field just runs together and I cannot place any formatting characters in (\n, \r, etc.) I do not know if I am doing it correctly and could use some help. I am trying to space the output out so that each field is separated by a tab, and every time the code loops a newline is put in so the information is readable. I am on a server hosted by godaddy which accepts php4 and php5. The code looks like this right now, and no matter where or how I enter the newline operators it doesn't work, although it never gives me an error message. [code]//This is an excerpt of the php code that connects to the database and retrieves the arraywhile($sql_array = mysql_fetch_array($sql)){ echo "<b><u>Company</u>: </b>".$sql_array["CompanyName"]."\t<b><u>Address:</u> </b>".$sql_array["Address"]."<b>, </b>".$sql_array["City"]."<b>. <u>\tPhone:</u> </b>".$sql_array["WorkPhone"]."\n";}</script>[/code]Does php not support this the way I am trying to do it? Link to comment https://forums.phpfreaks.com/topic/33859-basic-output-formatting-problem-with-php/ Share on other sites More sharing options...
scotmcc Posted January 12, 2007 Share Posted January 12, 2007 If you are outputting it to a web browser, I would try putting a break in "<br />".Scot Link to comment https://forums.phpfreaks.com/topic/33859-basic-output-formatting-problem-with-php/#findComment-158888 Share on other sites More sharing options...
Jessica Posted January 12, 2007 Share Posted January 12, 2007 A new line in html is [code]<br>[/code] Link to comment https://forums.phpfreaks.com/topic/33859-basic-output-formatting-problem-with-php/#findComment-158898 Share on other sites More sharing options...
hansenb88 Posted January 12, 2007 Author Share Posted January 12, 2007 I have tried every combination of newline returns I can think of and it is as if the loop isn't executing in an actual loop, rather just outputting a large string of text. Is there a problem with the syntax of my loop? and if not, where should I be putting the newline character in the line of php code shown above? Link to comment https://forums.phpfreaks.com/topic/33859-basic-output-formatting-problem-with-php/#findComment-158903 Share on other sites More sharing options...
hansenb88 Posted January 12, 2007 Author Share Posted January 12, 2007 I figured out the newline issue, but what is the proper syntax to place a tab in between each field on the output? Link to comment https://forums.phpfreaks.com/topic/33859-basic-output-formatting-problem-with-php/#findComment-158910 Share on other sites More sharing options...
scotmcc Posted January 13, 2007 Share Posted January 13, 2007 use:[pre] [/pre]to place a "tab" between data. This is 5 non-breaking space characters. Link to comment https://forums.phpfreaks.com/topic/33859-basic-output-formatting-problem-with-php/#findComment-159713 Share on other sites More sharing options...
trq Posted January 13, 2007 Share Posted January 13, 2007 Sounds like someone needs to learn html before they delve into php. :) Link to comment https://forums.phpfreaks.com/topic/33859-basic-output-formatting-problem-with-php/#findComment-159721 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.