Jump to content

Basic output formatting problem with php


hansenb88

Recommended Posts

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 array
while($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

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.