通过php函数增加HTML表行


Increment HTML table row through php function

我所做的基本上是有一个列表为例-thing1事件-thing3-thing4

的旁边都有一个ADD按钮当我按下添加按钮时,它会通过一个函数并弹出一个Html表行现在我想当我按下添加按钮时,它应该在html表中增加行,而不是覆盖它,请帮助!!

while($row = mysql_fetch_array($query2)){
      $id = $row['id'];
       echo "<tr style=background-color:#005566;color:white;>";
        //echo "<td>".$row['id']."</td>";
        echo "<td >".$row['name']."</td>";
        echo "<td >".$row['description']."</td>";
        echo "<td >".$row['quantity']."</td>";
        echo "<td >".$row['price']."</td>";
        echo "<td><a href='index.php?record=$id' class='btn btn-info' style=background-color:#005566;border:none;>ADD+</a></td>";
      // echo "<td><a href='medicine_delete.php?id=$id' style=color:white;text-decoration:none;>Delete</a> / <a href='medicine_update.php?edit=$id' style=color:white;text-decoration:none;>Edit</a></td>";

    }
    echo "</table>";
        if (isset($_GET['record'])) {
    displa_cart();
}

函数是

function displa_cart(){
        $id=$_GET['record'];
        global $dbc;enter code here
        $q=mysql_query("SELECT name,quantity FROM medicine where id='$id'");
        $num=mysql_num_rows($q);
        while ($fetch=mysql_fetch_assoc($q)) {
            echo "<form method='post' action='updaterecord.php'><input type='hidden' name='id' value='$id'><table class='table table-bordered' style='width:35%;position: relative;left: 250px;bottom: 340px;''>
                    <thead>
                        <tr class=info>
                            <th>Name</th>
                            <th>Quantity</th>
                        </tr>
                    </thead>"; 
                    echo "<tr><td>".$fetch['name']."</td>"."<td><input type=text name='qty' maxlength=3 value='$fetch[quantity]'></td></tr><br>";
                    echo "<tr><td><input type=submit value='Checkout'></td><td><input type=submit  value='update'></td></tr>";

        }
    echo "</table></form>";
    }

我的问题是,为什么你在while循环的每一次迭代中创建新的表,并在外面结束它?这不是问题吗?