获取表值html

时间:2014-09-07 12:42:57

标签: php mysql

我试图在按一下按钮后更新mySQL表..单击按钮不是问题,但我想知道如何获得klant_pk,这是更新mySQL中某条记录所特有的。如您所见,我首先打印出mySql表。所以有人知道我点击表格中的按钮后如何获得相应的klant_pk ..

谢谢

  $result = mysqli_query($con, "SELECT * FROM bestelling");
    echo "Bestellingen";
    echo "<table border='1' align='center'>
    <tr>
    <th>Bestelling_pk</th>
    <th>Klant_pk</th>
    <th>Product</th>
    <th>Commentaar</th>
    <th>Tijd</th>
    <th> Voortgang </th>
    <th> Status </th>


    </tr>";
        while ($row = mysqli_fetch_array($result)) {
            echo "<tr>";
            echo "<td>" . $row['bestelling_pk'] . "</td>";
            echo "<td>" . $row['klant_pk'] . "</td>";
            echo "<td>" . $row['product'] . "</td>";
            echo "<td>" . $row['opmerking'] . "</td>";
            echo "<td>" . $row['tijd'] . "</td>";
            echo "<td> <input type='button' value='In Wacht' onclick='return change(this);' />";
            echo "<td>" . $row['status'] . "</td>";
            echo "</tr>";       
        }

        echo "</table>";

1 个答案:

答案 0 :(得分:1)

while ($row = mysqli_fetch_array($result)) {
...
echo "<td id='klank_pk_".$row['klant_pk']."'>" . $row['klant_pk'] . "</td>";
...
echo "<td> <input type='button' value='In Wacht' onclick='change(getElementById('klank_pk_".$row['klant_pk']."').value);' />";
...
}