So i don't usually work with tables so i don't quite know how to extract the data from them, it might be something quite simple that i'm missing but going to the question, i have 3 tables generated from an array coming from sql (ignore the number of tables, assume that you don't know the exact number) and each table has an image, some strings and a button, my question is, how can i get the data from the table which the button was pressed and how can i distinguish it from the others?
//query the database
$ns = 'SELECT * FROM produtos';
$result = $conn-> query($ns);
if($result->num_rows !=0) {
$rowid = 0;
while ($row = $result->fetch_assoc()) {
$image = $row['nome_imagem'];
$rowid += 1;
$nome = str_replace('_', ' ', $row['nome_produto']);
echo "<form><table style='border: 1px solid black; margin-left: 10px; width: 99%'>",
"<tr class='$rowid'>",
"<th style='border:1px solid black; width: 100px; height: 200px;'>", "<img src='./css/images/$image' width='200px' height='200px' alt='produto'/>", '</th>',
"<th style='vertical-align: top; text-align: left; height: fit-content; width: 100%;'>", '<strong>'.$nome.'</strong>', "</th>",
"<th style='border:10px solid black;'>", '<br>', '<br>', '<br>' , '<br>' , "<div class='buycont'>", "<button onclick='addcart()' class='buy' style='height: 50px; background-color: #ff7b00; vertical-align: bottom;'><strong> Buy <i href='#' class='bi bi-cart'> </i></strong> </button>", "</div>", "</th>",
// "<td style='border:1px solid black; height: 10px'>", "ola" ,"</td>",
"</tr>",
"<tr style='border:1px solid black;'>",
"<td>" .$row['valor']. '€', "<tr>" ,'<br>',
"</tr>",
"</table> </form>";
}
echo "<br>";