Reputation: 502
if ($result->num_rows > 0)
{
while($row = $result->fetch_assoc())
{
echo "<form name=frm action=edit.php method=POST";
echo "<tr>";
echo "<td>" . $row["Sl_no"]. "</td>";
echo "<td> " . $row["nam"]. "</td>";
echo "<td> " . $row["age"]. " </td>";
echo "<td> " . $row["dob"]. "</td>";
echo "<td> " . $row["gender"]. " </td>";
echo "<td> " . $row["married"]. " </td>";
echo "<td> " . $row["temp_addr"]. " </td>";
echo "<td> " . $row["fix_addrs"]. " </td>";
echo "<td> " . $row["email"]. " </td>";
echo "<td> " . $row["phone"]. " </td>";
echo "<td> " . $row["mother_tounge"]. " </td>";
echo "<td> " . $row["nationality"]. " </td>";
echo "<td> " . $row["clg"]. " </td>";
echo "<td> " . $row["sem"]. " </td>";
echo "<td> " . $row["grad"]. " </td>";
echo "<td> " . $row["qual"]. " </td>";
echo "<td> " . $row["branch"]. " </td>";
echo "<td> <input type=submit name =" .$row["Sl_no"]. " value =Edit ><input type=button id=d".$row["Sl_no"]." value=Delete />";
echo "</tr>";
echo"</form>";
}
I am using this code and in each field there will be a random named submit will generate. I want to transfer the name of the button to next page or pass the value of first tag help me.
Upvotes: 0
Views: 927
Reputation: 11472
You need to pass the value from database to the submit button value, instead of name if you want to get the value on POST, because on post you're getting the name as key and value from input as values, like this:
<input type=submit name="name_here" value ="<?php echo $row['Sl_no']; ?>" >
Upvotes: 0
Reputation: 189
You can not post submit button value by using name attribute. just add one hidden field with this form. like
echo "<td> <input type=hidden value=" .$row["Sl_no"]. " name=submit_btn_val >"
Upvotes: 0
Reputation: 405
On the next page you can use $_POST['key']; or $_GET['key']. That will give you access to your value from the key.
Upvotes: 1