rasheemo Posted March 17, 2008 Share Posted March 17, 2008 hey guys, this is a piece of my code: while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['email'] . "</td>"; } what i wanted to do instead is put a button there (form) that when you click on it takes you to a page that lets you send an email to the $row['email'] person, but everytime i click any of the buttons on the table, it shows me the email of the very last person on the database, probably because the form doesnt submit the variable until i actually click the button, which by then has become the last entry. how can i solve this problem? thanks in advance! Quote Link to comment Share on other sites More sharing options...
Jeremysr Posted March 17, 2008 Share Posted March 17, 2008 It sounds like you only have one form with many buttons. You need 1 form for each row. while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['email'] . "</td>"; echo "<td><form action='email.php' method='post'><input type='hidden' name='email' value='" . $row['email'] . "' /><input type='submit' value='Send e-mail' /></form></td>" } That's how I'd do it. Quote Link to comment Share on other sites More sharing options...
rasheemo Posted March 17, 2008 Author Share Posted March 17, 2008 thanks a lot! that worked, even though i thought i did the same thing =] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.