0

I tried to search but was unable to find an answer for this question.

I am trying to get the value of the button in my submit button that is a variable.

CODE is as follows

$penrequest = "select * from request where status='pending';";
$penreg = mysql_query($penrequest);
echo "<form method='post' action=''>";
while ($row = mysql_fetch_array($peneg))
{
 echo "<input type='submit' name='answer' value='$appdeny'>";
}

if (isset($_POST['answer']))
{
   echo $appdeny;
}

Ok the code works...if you hit the button its caught by the if statement like its supposedt o be. the variable $appdeny is a messageID number filled from a mysql database which can change. When the user clicks a button i want to print the messageID of the number displayed as the value of the answer button.

3
  • pls show us the code for button Commented May 18, 2013 at 5:32
  • Your first line has an extra ; between the ' and the ". Your question is confusing me. I'm not even sure what you're really asking. Your question contains no question marks. Commented May 18, 2013 at 5:35
  • mysql_* are deprecated so avoid using them .. use mysqli_ or PDO Commented May 18, 2013 at 5:36

1 Answer 1

4

Change:

echo "<input type='submit' name='answer' value='$appdeny'>";

to:

echo "<input type='submit' name='answer' value='" . $row['appdeny'] . "'>";

Change:

echo $appdeny;

to:

echo $_POST['answer'];

You also need to do:

echo "</form>";

after the while loop.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. This worked perfect and achieved the goal i was going for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.