dqxmf02844 2013-09-23 16:51
浏览 9

根据表单字段显示相关信息

OK, Im working on an ordering system. When the user logs in they are presented with a list of vendors along with that vendors address and so on. Then under each vendor is a list of their product and box where they can input the quanity of each product they want.

I know how i can pass the quanity to the next page but im having trouble figuring out how im going to pass the vendor information for where the order is associated for instance if they placed an order for 25 of something for one vendor then on the confirm page it would put the quanity and diplay the vendor for which the order is associated.

My code is below. Any help will obviously be greatly appreciated and there's a chance i'll let you name my first born. Assuming i ever have kids and that's a big assumption.

<form name="OrderForm" action="/confirm" method="POST">
    <?php $query = 'SELECT * FROM Vendors WHERE VendorID = 1';
        $productquery = 'SELECT * FROM Products WHERE VendorID =  1';
$results = $db->getAll($query);
$productresults = $db->getAll($productquery);?>
 <table class="table">
              <thead>
                <tr>
                  <th>Quantity/Product</th>
                  <th>Category</th>
                  <th>Vendor</th>
                  <th>Address</th>
                </tr>
<?php

foreach ($results as $vendor) {
?>
<tr class="category">
    <td></td>
    <td><?php echo $vendor['Category'];?></td>
    <td><?php echo $vendor['Vendor'];?></td>
    <td><?php echo $vendor['Address'];?></td>

    </tr> 
    <?php

 foreach ($productresults as $product){
    ?>

     <tr class="product">
    <td colspan="4"><span class="name"><input type="text" name="quantities[]" size="1" /><?php echo $product['Product'];?></span></td>

    </tr>
    </table>
<input type="submit" value="Checkout"<button style="float:right;" type="button" class="btn btn-primary"></button>
</form>
  • 写回答

1条回答 默认 最新

  • duanming7833 2013-09-23 17:12
    关注

    When you link them to the next page, use something like orderpage.php?vendor=$vendor[vendor] or the vendor ID, so you can grab the vendor info from the next page. You can do it like this:

    <td><a href="orderpage.php?vendor=<?php echo $vendor['Vendor'];"?>> <?php echo $vendor['Vendor'];?> </td></a>

    In order to get the vendor value from the url, you do the following:

    $vendor = $_GET['vendor'];

    And you will have the necessary information to run a query and grab all the vendor info. That's the easiest way.

    IMPORTANT: Make sure to filter $vendor variable appropriately, as users can and will try to mess with it by adding code after ?vendor=, so depending on what value you want to pass (id number, special character, vendor name etc) filter the $_GET['vendor'] so only your information can be passed to the query.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。