English 中文(简体)
定购制度——每条单(不是流)的粗略数字
原标题:Ordering system - id number per order (not row) in mysql

这部法典有98%已经实施,但在最后一行挣扎。 I m 建立一个订购系统,一页从一个网页上提取价值,将其送到一个存放点的网页上,并插入一页象:

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die("Cannot connect to mysql server");
           mysql_select_db($dbname) or die("Cannot select database");

            if (isset($_POST[ data ]) && is_array($_POST[ data ])) {
                foreach ($_POST[ data ] as $row => $data) {
                    $result = mysql_query("INSERT INTO orders (id,project_ref,supp_short_code,om_part_no,description,quantity,cost_of_items,cost_total) VALUES(  ,  ".$data[ project_ref ]." ,  ".$data[ supp_short_code ]." ,  ".$data[ om_part_no ]." ,  ".$data[ description ]." ,  ".$data[ quantity_input ]." ,  ".$data[ cost_of_items ]." ,  ".$data[ cost_total_td ]." ) ") or die(mysql_error());
                }
            }

哪些是巨大的(而且我知道,i m不保护不遭受q的注射等),但可以用上述代码将多行插入b,但用户今后需要能够撤回基于一 number数目的命令。 因此,如何在此处插入一个id号,使之与所有各行相匹配,在 d和理想的自动加固中无疑是独一无二的(如果人们知道,在多行的情况下,会trick!)

最佳回答

我在类似情况下所做的是两个表格:ordersorder_detail

<代码> 表格有<编码>grand 共计s,orderdate/code>,customer id等。

。 表格将包含每个项目的条目:part_no,quantity,cost,extised_cost,但与s链接 www.un.org/spanish/ga/president

您最后选择:

www.un.org/spanish/sc/presidency.asp 目 录 JOIN Order_detail ON Order.order_id = Order_detail.order_id WHERE Order.order_id = 1

问题回答

添加一个栏目: 表格BatchID。 之后,在PHP中形成一个GUID,并相应修改INSERT的说明。

http://php.net/manual/en/Function.com-create-guid.php>rel=“nofollow”> 详见关于建立国际统一私法协会的详情。

function GUID()
{
    if (function_exists( com_create_guid ) === true)
    {
        return trim(com_create_guid(),  {} );
    }

    return sprintf( %04X%04X-%04X-%04X-%04X-%04X%04X%04X , mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
}

假定贵方的田地是为了为每一条秩序规定自动加油的门,在您目前的发言之前,你想添加一个新字,在一张带有自动加固主要钥匙的桌子上添加一个记录。 然后,将这一新的主要关键因素与你目前的表态联系起来,而不是现在的粗略或除现在的外。

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die("Cannot connect to mysql server");
       mysql_select_db($dbname) or die("Cannot select database");

        if (isset($_POST[ data ]) && is_array($_POST[ data ])) {
            result = mysql_query("INSERT INTO orders_to_order SET order_primary = NULL");
            $orderId = mysql_insert_id();
            foreach ($_POST[ data ] as $row => $data) {
                $result = mysql_query("INSERT INTO orders (id,project_ref,supp_short_code,om_part_no,description,quantity,cost_of_items,cost_total) VALUES(".$orderId.",  ".$data[ project_ref ]." ,  ".$data[ supp_short_code ]." ,  ".$data[ om_part_no ]." ,  ".$data[ description ]." ,  ".$data[ quantity_input ]." ,  ".$data[ cost_of_items ]." ,  ".$data[ cost_total_td ]." ) ") or die(mysql_error());
            }
        }




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签