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! Link to comment https://forums.phpfreaks.com/topic/96489-variable-keeps-changing-as-i-traverse-database/ 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. Link to comment https://forums.phpfreaks.com/topic/96489-variable-keeps-changing-as-i-traverse-database/#findComment-493818 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 =] Link to comment https://forums.phpfreaks.com/topic/96489-variable-keeps-changing-as-i-traverse-database/#findComment-493820 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.