通过php函数

时间:2016-10-20 02:35:02

标签: javascript php jquery html html-table

我在做什么基本上就是列表 -thing1 -thing2 -thing3 -thing4

并且每个旁边都有一个ADD按钮 当我按下添加按钮时,它会通过一个功能并弹出一个Html表格行 现在我想要当我按下添加按钮for 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>";
    }

1 个答案:

答案 0 :(得分:0)

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