繁体   English   中英

通过php函数增加HTML表格行

[英]Increment HTML table row through php function

我在做什么基本上有例如-thing1 -thing2 -thing3 -thing4的列表

当我按下添加按钮时,每个按钮旁边都有一个ADD按钮它会通过一个功能并弹出一个Html表格行现在我想要当我按下添加按钮for thing2它应该在html表中增加行而不是覆盖它帮助PLS! !

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>";
    }

我的问题是,为什么你在每次迭代循环时创建新表并在外部结束? 不是问题吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM