Jump to content

Recommended Posts

how can i use php to enter records into mysql using a transaction ;

I have this stored procedure below.how can i excute itt using php to insert data from an array like this one:
Array
(
    [Japanese] => Array
        (
            [hot] => wasabi
           
[salty] => soy sauce
       
[sweety] => soy rdsauce
       
[bitter] => pepper sauce
       
)

    [Chinese] => Array
        (
            [hot] => wasabi
           
[salty] => soy sauce
       
[sweety] => soy rdsauce_one
       
[bitter] => pepper sauce3
       
)

    [indian] => Array
        (
            [hot] => wasabi
           
[salty] => soy sauce
       
[sweety] => soy rdsauce
       
[bitter] => pepper sauce4
       
)

    [mexican] => Array
        (
            [hot] => soanzo
           
[salty] => soy sauce1
       
[sweety] => soy sauceeur
       
[bitter] => pepper sauce_sausage
       
)

    [russian] => Array
        (
            [hot] => soanzo
           
[salty] => soy sauce1
       
[sweety] => soy sauceeur
       
[bitter] => pepper sauce_pork

       
)

    [ganda] => Array
        (
            [hot] => soanzo
           
[salty] => soy sauce1
       
[sweety] => soy sauce_beef
       
[bitter] => luwombo_chicken

       
)

)

i have tried this so far but no good:

    include("config.php");

    $strat_sql="call sp_addnewetails(?,?,?,?,?,?)";
    $insert_t_stmt=$mysqli->prepare($strat_sql)or die($mysqli->error);
         #associate variables with the input parameters
    $insertt_stmt->bind_param("isssss",$my_prioid,$my_planid,$my_outcome_id,$my_Activities_id,$my_performanceIndicator_id,$my_target_id); #i=integer
        //aggregate the records to save
        $my_prioid =$_POST['strat_priorities'];
        $my_planid=stripslashes($plan);
     for ($i = 0, $num_specials = count($arr); $i < $num_specials; $i++) {
         for ($m = 0, $num_sub = count($arr[$i]); $m < $num_sub; $m++) {
     //save record
        $my_id=stripslashes($arr[$i][$m]);
        $my_Act_id=stripslashes($arr[$i][$m]);
        $my_p_id=stripslashes($arr[$i][$m]);
        $my_t_id=stripslashes($arr[$i][$m]);
         #Execute the statement
        $insert_t_stmt->execute( ) or die ($insert_t_stmt->error);
        $insert_t_stmt->bind_result($Entryerr);
        while ($insert_strat_stmt->fetch( )) {
             $error12=$Entryerr;
            if(substr($error12,0, 4)=="succ"){$suc=$error12;}
        }    


         }//inner for
     }
$insert_t_stmt->close( );
$mysqli->close( );

 

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.