1个ID,以获取更多物品 [英] 1 id for more items
问题描述
我有一个request_form.php表单,用于管理请求项目的购买请求表单.
I have a form request_form.php, that is manage Purchase Request Form for request item.
Purchase_Request_No :(自动-自动递增)
日期:
部门:
供应商:
Item_Request:
例子有5行:
1.
2.
3.
4.
5.
Purchase_Request_No : (automatic - autoincrement)
Date :
Dept :
Supplier :
Item_Request :
Example have a 5 row :
1.
2.
3.
4.
5.
我想在一次购买请求中有1个Purchase_Request_No.
例子:
Purchase_Request_No:17
日期:2012年7月25日
部门:生产
供应商:Microsoft
Item_Request:
1.Windows XP Professional
2.键盘
3.鼠标
4.液晶显示器
5.扬声器
I want to make once Purchase Request have 1 Purchase_Request_No.
Example :
Purchase_Request_No : 17
Date :25-Jul-2012
Dept :Production
Supplier :Microsoft
Item_Request :
1.Windows XP Professional
2.Keyboard
3.Mouse
4.LCD Monitor
5.Speaker
那么,如果项目请求超过1个项目(在这种情况下,我放置了5个项目),我如何用1个Purchase_Request_No来实现?
So, how can I make it with 1 Purchase_Request_No with item request more than 1 item(in this case I put 5 items)?
任何人都可以帮助我吗? 感谢您的进阶.
Anyone can help me ? Thanks for advance.
大家好,现在又回来,我已经在编写概念了.
它已成功将数据保存到数据库中,但是当插入5个项目时,仍会按ID为每个项目提交数据.
例子:
项目1-计算机(采购1)
项目2-鼠标(购买编号2)
我想要的是:
项目1-计算机(采购1)
项目2-鼠标(购买1)
Hi all, back again now I already in coding the concept.
It's successfully save the data into database, but still when insert 5 item, it submit the data per item per ID.
Example :
Item 1 - Computer (Purchase No 1)
Item 2 - Mouse (Purchase No 2)
That I wanted is :
Item 1 - Computer (Purchase No 1)
Item 2 - Mouse (Purchase No 1)
这是我的代码: 我使用自动购买的购买编号.
and here it's my code : I using purchase no with autoincrement.
<?php
$conn = oci_connect("system", "dev01");
$n = $_POST['jum'];
for ($i=1; $i<=$n; $i++)
{
$dept=$_POST['dept'];
$date_request=$_POST['date_request'];
$supplier=$_POST['supplier'];
$item=$_POST['item'.$i];
$qty=$_POST['qty'.$i];
$uprice=$_POST['uprice'.$i];
$total=$_POST['total'.$i];
$s = oci_parse($conn,
"insert into purchase_request(dept_id, supplier_id, date_request, item, qty, uprice, total_amount) values ('$dept', '$supplier', '$date_request', '$item'
, '$qty', '$uprice', '$total'
)");
$r = oci_execute($s);
oci_rollback($conn);
echo "Data was committed\n";
}
?>
有什么主意吗?
推荐答案
具有三个表.一个将包含以下产品:
Have three tables. One would contain the products:
id Product
1 Windows XP Professional
2 Keyboard
3 Mouse
4 LCD Monitor
5 Speaker
另一个包含请求:
id request_date dept supplier
1 25-Jul-2012 Production Microsoft
第三个将前两个映射在一起
The third maps the first two together
id request_id item_id
1 1 1
2 1 2
3 1 3
4 1 4
5 1 5
(或者,您可以将商品的ID设为质数,并将items
列存储为多个项目的倍数.您要做的就是找到items
列的质因数,然后那么您就有了物品清单!*)
(Alternately, you could make the ids of the products prime numbers and store the items
column as a multiple of the items. All you'd need to do is find the prime factors of the items
column, and then you've got the list of items!*)
*由于某种原因,没有人认为这是个好主意.
*For some reason, no one at work thinks this is a good idea.
这篇关于1个ID,以获取更多物品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!