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? Quote Link to comment 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 Quote Link to comment 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] Quote Link to comment 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? Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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. :) 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.