Jump to content

variable keeps changing as i traverse database


rasheemo

Recommended Posts

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!

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.