[Solved] how to give specification for button in php when it is in while loop [closed]


Currently you are using one big <form> element for all your entries. When sending that form, the actual values get overridden many times and you just see the last one.

To solve this, you could, e.g., make a form out of every entry like this:

echo "<html>";

$c = mysql_connect("localhost", "root", "");
mysql_select_db("test", $c);
$query = mysql_query("select * from age");

while ($s = mysql_fetch_row($query))
{
    echo "<form method=post><table><tr><td>Name   :<textarea rows=5 cols=5 name=name>$s[0] </textarea></td></tr><tr><td>Age   :<textarea rows=5 cols=5 name=age>$s[1] </textarea></td></tr><tr><td><input type=submit value="click" name=submit></td></tr></table></form>";
}

if (isset($_POST['submit']))
{
    $name = $_POST['name'];
    $age=$_POST['age'];
    echo "name is $name";
    echo "age is $age";
}
// ... rest of the code ...

Anyway, the mysql functions, you use, are deprecated. Have a look at PDO or mysqli as a replacement!

2

solved how to give specification for button in php when it is in while loop [closed]