English 中文(简体)
插入多个项目,作为单一项目
原标题:multiple items being inserted as one item into db

我正试图接受多种物品,从形式和到达地点时,用于加工、分立物品,并将它们作为适当物品处理,插入db。 目前发生的情况是,这些项目正作为一个项目列入b。 例如,我进入项目1,项目2,项目3。 这正列入一个栏目。 一栏中所有三个项目。 我如何纠正我的法典,把每个项目放在自己的一栏。 很多人

php page

foreach($_POST[ BRVbrtrv_boxnumber ] as $i=>$value){
$_POST[ BRVbrtrv_boxnumber ][$i]=mysql_real_escape_string($value);
}

$boxnumber = implode(  , , $_POST[ BRVbrtrv_boxnumber ]);

$query =  INSERT INTO `act` (`service`, `activity`, `department`, `company`,  `address`, `user`, `item`, `destroydate`, `date`, `new`)
         VALUES (  .$service.  ,   .$activity.  ,   .$department.  ,   .$company.  ,   .$address.  ,   .$authorised.  ,   .strtoupper($boxnumber).  , NULL, NOW(),   .$new.  ); ;
mysql_query($query) or die( Error, query failed );

分类投入

for(var i = 0;i < $(this).val();i++) {
$("#BRVbrtrv_boxnumber").append( <div data-role="fieldcontain"><label for="BRVbrtrv_boxnumber" class="ui-input-text">Enter box   + (i + 1) +   number:</label><input type="text" name="BRVbrtrv_boxnumber[ +i+ ]" id="BRVbrtrv_boxnumber[ +i+ ]" class="BRV_boxnumber ui-input-text ui-body-null ui-corner-all ui-shadow-inset ui-body-c" /></div> )
}

json output

boxnumber: "rff,tgg" <- this is correct values for 2 items that I input

+++UPDATE+++

    foreach($_POST[ BRVbrtrv_boxnumber ] as $i=>$value){
            $_POST[ BRVbrtrv_boxnumber ][$i]= strtoupper( mysql_real_escape_string($value) );
    }

    foreach( $_POST[ BRVbrtrv_boxnumber ] as $k => $item_name ){

    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
    header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" );
    header("Cache-Control: no-cache, must-revalidate" );
    header("Pragma: no-cache" );
    header("Content-type: application/json");
    $json = "";
    if(empty($service)) {
    $json .= "{"ErrorService": "ERROR: You mest select a service level"}";
     }

    else
    if($department=="Choose Department") {
    $json .= "{"ErrorService": "ERROR: You must select a department"}";
     }

    else
    if($address=="Choose Address") {
    $json .= "{"ErrorService": "ERROR: You must select a retrieval address"}";
     }

    else
    if(empty($item_name)) {
    $json .= "{"ErrorService": "ERROR: You must enter a box for retrieval"}";
     }

    else
    {
    $json .= "{
";
    $json .= ""boxnumber": "".$item_name."",
";
    $json .= ""boxcount": "".$boxcount.""
";
    $json .= "}
";
    }
 }
最佳回答
foreach($_POST[ BRVbrtrv_boxnumber ] as $i=>$value){
        $_POST[ BRVbrtrv_boxnumber ][$i]= strtoupper( mysql_real_escape_string($value) );
}

foreach( $_POST[ BRVbrtrv_boxnumber ] as $k => $item_name )
{

    $query =  INSERT INTO `act` (`service`, `activity`, `department`, `company`,  
                                 `address`,  `user`, `item`, `destroydate`, `date`
                                 ,`new`)
   VALUES (  .$service.  ,   .$activity.  ,   .$department.  ,   .$company.  ,    .$address.  ,   .$authorised.  ,   .$item_name.  , NULL, NOW(),   .$new.  ); ;
mysql_query($query) or die( Error, query failed );
} 
问题回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签