PHP循环使用创建表单但单击哪一个?

Hey i am using a PHP loop to create a table where each row in the table is a form. This part is fine.

I am now stuck. When i press submit it does not matter which form i press the submit button for it just passes the values from the last form to my php script.

Is there a way to know which button has been clicked? each of the fields are unique as i am using a row counter.

echo'  <input type="hidden" name="buyerID'.$rowcounter.'" value="'.$buyerID.'">';

So if i knew which form was submitted i could use

$buyerID= $_POST['buyerID'.$formnumber];

to get the values that i want but i cannot work out what to do. I thought that by creating multiple forms it would submit the value of the form submitted but this does not seem to be the case.

This is my table code:

<table class="table mb-0">
   <thead>
 <tr>
   <th></th>
   <th>Name</th>
   <th>Address</th>
   <th>Post Code</th>
   <th>City</th>
     </tr>
    </thead>
   <tbody>
    <tr>  <td>
    <form action="companyRating.php" method="post" name="myForm1"> 
    <input type="submit" value="Select" name="formbutton1" id ="formbutton1" class="linkButton" />
<input type="hidden" name="buyerID" value="033f4480-cdeb-44d9-b23f-17fb017f1ab5">
<input type="hidden" name="buyerName" value="CORVINVIEW LIMITED">
<input type="hidden" name="invoiceValue" value="2000">
<input type="hidden" name="issueDate" value="2018-04-02">
<input type="hidden" name="regNumber" value="01737132">
<input type="hidden" name="buyerStreet" value="UNION WORKS">
<input type="hidden" name="buyerPostCode" value="E10 5DJ"> 
<input type="hidden" name="buyerCity" value="LONDON">
<input type="hidden" name="buyerCountry" value="GB">
</form>
</td>  
<td><div id="buyerName" title="CORVINVIEW LIMITED">CORVINVIEW LIMITED</div></td>  
<td><div id="buyerStreet1">UNION WORKS<div></td>  
<td>E10 5DJ</td>  
<td>LONDON</td></tr>
<tr>  <td>
<form action="companyRating.php" method="post" name="myForm2"> 
<input type="submit" value="Select" name="formbutton2" id ="formbutton2" class="linkButton" />
<input type="hidden" name="buyerID" value="21d123c8-06f9-4279-93ba-4d69307b9ea7">
<input type="hidden" name="buyerName" value="CORRIBVIEW SAFETY SERVICES LIMITED">
<input type="hidden" name="invoiceValue" value="2000">
<input type="hidden" name="issueDate" value="2018-04-02">
<input type="hidden" name="regNumber" value="0574526">
<input type="hidden" name="buyerStreet" value="CORRIBVIEW SLIEVEROE">
<input type="hidden" name="buyerPostCode" value="">
<input type="hidden" name="buyerCity" value="HEADFORD">
<input type="hidden" name="buyerCountry" value="GB">
</form>
</td>  
<td><div id="buyerName" title="CORRIBVIEW SAFETY SERVICES LIMITED">CORRIBVIEW SAFETY SERVICES LIMITED</div></td>  
<td><div id="buyerStreet1">CORRIBVIEW SLIEVEROE<div></td>  
<td></td>  
<td>HEADFORD</td>
   </tr>                  
</tbody>
</table>

It doesn't matter if i select the first form on the 2nd the values of the 2nd are always sent

You already said each row in the table is a form. Then the submit button within the row belongs to the form for said row.

To figure out, which row this is, the name should remain constant for all forms:

echo '<input type="hidden" name="buyerID" value="'.$buyerID.'">';

So, to figure out which buyerID was used, simply fetch it from the post data:

$buyerID = $_POST['buyerID'];