dpbl91234 2016-05-06 23:19
浏览 271

使用php从外部文件生成唯一的提交按钮

So what I'm trying to do is create a shopping cart webpage that takes information from a csv file and then generates the webpage using the information from the csv file. In this csv file, there is the price of the item, how much is in stock, and the picture of the item. The code below is able to generate all of this and this is a screenshot of what I have so far: https://gyazo.com/2f14eff68d156cd6d9cb93fd66418760

Now I want to have "order" buttons beneath each item. I am having trouble understanding how I can generate an order button for each item and make each order button unique. I know I need to make this order button submit information for that specific 'container' and not information of the orders but I'm not sure how to make each item unique. Sorry if these questions are elementary. I'm not very experienced with php.

if (($handle = fopen("assign6.csv", "r")) !== FALSE) {

while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
    $num = count($data);
    echo "<div id = 'container'>
            <figure>
          <p style='float: right; font-size: 20pt; text-align: center; width: 20%; margin-right: 10%; margin-bottom: 0.30em;'>
          <img src=$data[2] height = '200' width = '200' ><br>$data[1]<br>Stock: $data[3]<br>$$data[4] </p>     
          </div>    
          </figure>";

}
fclose($handle); }
  • 写回答

2条回答 默认 最新

  • douben1891 2016-05-06 23:23
    关注

    When you have a form with multiple <button> or <input type="button">, the form handler only receives the value of the clicked button. So... That's it, assign the same name to every button and a unique value to each one. Or other option is to use links with GET arguments.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题