I am quering a database and buiding a form with the information in the database. For one person in the database they have three addresses. I put mysql_fetch_array in a while loop to make sure I gather all the fields. When I do this, my output is three different forms. All the information is the same on each form except for the address boxes where in each form the address is different. Atleast I know that it is getting the different address but it is putting each address in a seperate form. this is my some of my code.
<?php
if($numRows > 0)
{
while($rows = mysql_fetch_array($result))
{
echo '<form action="" method="post">
<table width="98%" border="0" align="center" cellspacing="2">
.
.
.
.
</table>
</form>';
}
}
?>
I just echoed my whole form to display it.
Please help
How do I print out one form????
Moderator: General Moderators
-
TheBentinel.com
- Forum Contributor
- Posts: 282
- Joined: Wed Mar 10, 2004 1:52 pm
- Location: Columbus, Ohio
Re: How do I print out one form????
If it's ok to use the first address you find, you can put a break at the end of your loop:
Hope that helps! (And works, I didn't test it, but it looks right)
Code: Select all
<?php
if($numRows > 0)
{
while($rows = mysql_fetch_array($result))
{
echo '<form action="" method="post">
<table width="98%" border="0" align="center" cellspacing="2">
.
.
.
.
</table>
</form>';
break; // will terminate after the first record is processed
}
}
?>