Problem With Returned Record Set

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dgny06
Forum Commoner
Posts: 25
Joined: Thu Jun 14, 2007 11:35 pm

Problem With Returned Record Set

Post by dgny06 »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Thank you in advance for any help....

I am having a problem returning a basic record set on a page. The problem is that my code is returning a new table for every record in my query. Now I know that I have the table tag inside of the echo command but I can not figure out how to tweak it to be one table. Thanks again.

Code: Select all

<?PHP

			  	$ViewAllAddresses = 'SELECT * FROM  tbPerson';
   				$ReturnedAddresses = mysql_query($ViewAllAddresses);
 
 	    			while($Record = mysql_fetch_assoc($ReturnedAddresses))
					{
					
					$fname = $Record["FirstName"]; 
					$lname = $Record["LastName"]; 
					$addr1 = $Record["Address1"]; 
					$addr2 = $Record["Address2"]; 
					$city = $Record["City"]; 
					$state = $Record["State"]; 
					$zip = $Record["Zip"]; 
					$hphone = $Record["HomePhone"]; 
					$bphone = $Record["BusinessPhone"]; 
					$cphone = $Record["CellPhone"]; 
					$email = $Record["Email"]; 
    
	
    				echo "
					<table align="center" border="1"><tr>
					<td>$fname</td>
					<td>$lname</td>
					<td>$addr1</td>
					<td>$addr2</td>
					<td>$city</td>
					<td>$state</td>
					<td>$zip</td>
					<td>$hphone</td>
					<td>$bphone</td>
					<td>$cphone</td>
					<td>$email</td>
					</tr></table>";

					}
				
?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Move the table tags to separate echoes before and after the loop.
dgny06
Forum Commoner
Posts: 25
Joined: Thu Jun 14, 2007 11:35 pm

Post by dgny06 »

that worked....thank you so much
Post Reply