0
while($row = mysql_fetch_assoc($req))
    {
        $user_from = $row['user_from'];
        echo "<form method='post'><a href='".$row['user_from']."' name='yo' value'".$row['user_from']."'>".$row['user_from']."</a> &nbsp";
        echo "<input type='submit' name='acc' value='Accept'> &nbsp <input type='submit' name='cancel' value='Reject Rrquest'></form> <br/><br/>";
    }
    if(isset($_POST['acc']))
    {
    }   

Blockquote

//on submit here i need to disply corresponding $row['user_from'] value

Rahul
  • 19
  • 5
  • 1
    Welcome to [so]! At this site you are expected to try to **write the code yourself**. After **[doing more research](//meta.stackoverflow.com/questions/261592)** if you have a problem you can **post what you've tried** with a **clear explanation of what isn't working** and providing a [**Minimal, Complete, and Verifiable example**](//stackoverflow.com/help/mcve). I suggest reading [ask] a good question and [the perfect question](http://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/). Also, be sure to take the [tour] and read **[this](//meta.stackoverflow.com/questions/347937/)**. – John Conde Jul 21 '17 at 10:48
  • FYI, [you shouldn't use `mysql_*` functions in new code](http://stackoverflow.com/questions/12859942/). They are no longer maintained [and are officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). See the [red box](http://php.net/manual/en/function.mysql-connect.php)? Learn about [*prepared statements*](https://en.wikipedia.org/wiki/Prepared_statement) instead, and use [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) - [this article](http://php.net/manual/en/mysqlinfo.api.choosing.php) will help you decide which one is best for you. – John Conde Jul 21 '17 at 10:48
  • just stroe this to hidden input $row['user_from'] . you will get in post value – sekaraja Jul 21 '17 at 10:59
  • Hi. Please go through this link on how to ask a question in StackOverflow https://stackoverflow.com/help/how-to-ask – Karthik Venkatraman Jul 21 '17 at 11:08

2 Answers2

-1

Use <input type="hidden" name="whateveryouwant" />, if you don't want to display text field to user.

Try this:

while($row = mysql_fetch_assoc($req))
{
    $user_from = $row['user_from'];
    echo "<form method='post'><input type='hidden' name='user_from' value='".$row['user_from']."' /><a href='".$row['user_from']."' name='yo' value'".$row['user_from']."'>".$row['user_from']."</a> &nbsp";
    echo "<input type='submit' name='acc' value='Accept'> &nbsp <input type='submit' name='cancel' value='Reject Rrquest'></form> <br/><br/>";
}
if(isset($_POST['acc']))
{
    echo $_POST['user_from'];//echo the value of user_form
}   
Ankit Singh
  • 1,477
  • 1
  • 13
  • 22
-1
<?php

while($row = mysql_fetch_assoc($req))
    {
        $user_from = $row['user_from'];
     ?>


    <form method="post" action="">
      <a href="<?php $row['user_from'] ?>" name="yo" value ="<?php $row['user_from'] ?>"> <?php $row['user_from'] ?> </a>

      <input type="submit" name="acc" value="Accept">

      <input type="submit" name="cancel" value="Reject Rrquest">

    </form>

     <php
     }
    ?>

<?php
    if(isset($_POST['acc']) && !empty($_POST['yo']))
    {
        $link = $_POST['yo'];  
        // do what you want to do with this `url`
    }   

?>

NOTE: Don't Complex Your Code With Using Html COde In Php echo. You Can Just Open the While Loop Brackets { and then close the php ?> then simple html you have to written, So Just Avoid to used html code inside the php echo

RïshïKêsh Kümar
  • 4,734
  • 1
  • 24
  • 36