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
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?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.