php - I couldn't pass the variable in the data display code to another database code(this connects with the databse) -
i retrieve data database , present data in text boxes, user can edit them. there multiple rows user can edit. in order number of records present user, have used variable called count. cant use variable in php database code.
part of data display code
while($row = mysqli_fetch_array($result)){ echo '<form action = "updateitem.php" method="post">'; echo "<tr>"; echo "<td>" . $row['item_id'] . "</td>"; echo"<td ></td>"; $id[] = $row['item_id']; echo "<td>" . $row['buyingprice'] . "</td>";echo"<td></td>"; $sellingprice = $row['sellingprice']; echo "<td>"."<input type ='text' name = \"sellingprice".$count."\" value ='".$sellingprice."'>"."</td>"; $stockqty = $row['stockqty']; echo "<td>"."<input type ='text' name = \"stockqty".$count."\" value ='".$stockqty."'>"."</td>"; $count = $count + 1; echo "</td>"; echo "</tr>"; } echo "</table>"; ?> <div id=""> <input type="submit" class="mybutton" id="btnmanagestockupdate" name="btnmanagestockupdate" value="update" /> </div> <?php echo "</form>";
php database code
echo ("sellingprice".$x); $sellingprice = $_post['sellingprice'.$x]; $stockqty = $_post['stockqty'.$x]; $sql = "update item set sellingprice = $sellingprice,stockqty = $stockqty item_id = $id[$x]"; $result = mysqli_query($dbcon,$sql); } } ?>
create hidden input field name count , pass count variable it
<input type="hidden" value="<?php $count?>" name="count">
so @ end of loop store final count can use iterate loop in php database code.
Comments
Post a Comment