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!

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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