简体   繁体   English

有什么方法可以存储表中使用的按钮的ID?

[英]Is there a way I could store id of my button used in a table?

<?php
     while($row = mysqli_fetch_array($results)){
?>
  <tbody>
    <tr>
      <td> <?php echo $row['Product_ID'] ?></td>
      <td> <?php echo $row['Product_Name'] ?></td>
      <td> <?php echo $row['Product_Price'] ?></td>
      <td> <?php echo $row['Product_Stock'] ?></td>
      <td> <button type="submit" name="add" id="<?php $row['Product_ID'] ?>" onclick="func(<?php $row['Product_ID'] ?>)"> Add </button></td>    
    </tr>

<?php } ?>`

<script type="text/javascript" method="post">
    function func(id){
        window.alert(id); 
    };
 </script>

Is there a way I could store id of my button named add? 有没有一种方法可以存储名为add的按钮的ID? I've to store multiple product ids and use them in a receipt that would be generated using product ids. 我必须存储多个产品ID,并在使用产品ID生成的收据中使用它们。 the method of the form is POST but I don't know how to get the id 表单的方法是POST但我不知道如何获取ID

Replace this 取代这个

 func(<?php $row['Product_ID'] ?>)

With This 有了这个

 func(<?php echo $row['Product_ID']; ?>)

暂无
暂无

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

相关问题 如果我在CodeIgniter中使用函数或类来生成表来存储我的用户信息,这是否安全? - It is secure or possible or not if I used function or class in CodeIgniter to generate table to store my user information? 在我的图书馆管理系统中传递id和button单击参数后,我想以表格格式显示结果 - I want to display my results in table format after passing a parameter of id and button click in my library management system 将按钮ID存储到php中的变量中 - Store a button id into a variable in php 我的域已用于提供网络钓鱼站点。 我认为他们使用过Apache重定向。 有人可以救我吗? - My domain is being used to serve a phishing site. They have used used Apache redirection I think. Could somebody rescue me? 哪种方法可以在数据库中存储和处理大量数据? 将所有内容存储在一个表中,还是通过ID(属性)为每个表创建新表? - Which way is legitimate to store &process big amounts of data in database? Store all in one table or create new table by id (property)for each? Magento无法使用商店ID保存静态块 - Magento could not save static block with store id Mysql 连接允许将 ID 用作链接表的 null 值的内部连接上的按钮链接 - Mysql join allowing ID to be used as a button link on inner join on null value of linked table 如何获取我在表中选择的数据行的 ID? - How can I get the id of the datarow I selected in my table? 我是否应该在图像表中存储评论/喜欢/不喜欢的次数? - Should I store number of comments/likes/dislikes in my image table? 如何将这些多个值存储在MySQL表中? - How should I store these multiple values in my MySQL table?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM