【问题标题】:Increment HTML table row through php function通过php函数增加HTML表格行
【发布时间】:2017-03-01 20:48:17
【问题描述】:

我在做什么基本上是有列表例如 -东西1 -东西2 -东西3 -thing4

每个旁边都有一个添加按钮 当我按下添加按钮时,它会通过一个函数并弹出一个 Html 表格行 现在我想当我按下thing2的添加按钮时,它应该增加html表中的行而不是覆盖它HELP 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>";
    }

【问题讨论】:

    标签: javascript php jquery html html-table


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-09-27
      • 2013-04-22
      • 2012-06-14
      • 1970-01-01
      • 1970-01-01
      • 2017-08-07
      相关资源
      最近更新 更多