Jump to content

Recommended Posts

Hello everyone,

 

I have a small problem that I can't seem to figure out but I'm sure there's a way to accomplish what I'm trying to achieve.  Here's my problem:

 

I have a table that has contact information that I want to place in a single string but format the output in the following manner.

 

John Doe                                  Richard Smith     

124 S Main Street                      1001 N Liberty Dr.

Mount Vernon, Ohio 43050            New Jersey, NY 23334

 

Jane Smith                                Damian Clem     

133 N Main Street                      2222 N Liberty Dr.

Mount Vernon, Ohio 43050            New Jersey, NY 23334

 

So, the output has two columns of data.  I can't figure out how the loop would be handled to create the two columns.  From left to right the loop would create contact one information > contact two information > next line > contact three info > contact four > until $contactinfo has no data left to display.

 

 
<?
       while ($contactinfo = mysql_fetch_assoc($contacts)) {	

	$output  = ' ' .$contactinfo['first_name']. ' ' .$contactinfo['last_name']. '\n';
	$output .= ' ' .$contactinfo['street']. '\n';
	$output .= ' ' .$contactinfo['city']. ' '. .$contactinfo['state']. ' ' .$contactinfo['zip'].'\n\n';
       }
?>

 

Thanks for any help provided on this one.

Link to comment
https://forums.phpfreaks.com/topic/164546-format-output/
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.