php - how to insert multiple data in one field with different id? -


this question exact duplicate of:

here code. insert last element value. want insert value in 1 field different id , data insert in different different row.

    public function update($user_slider, $user_welcomebox, $user_servicebox, $user_postbox, $user_testimonials, $user_welcomemessage, $user_welcomededcription, $user_welcomelink, $user_welcomelinktitle, $user_servicetitle, $user_totalservicedisplay, $user_ourservice, $user_blogtitle, $user_totalblogdisplay,$user_ourblog, $user_newstitle, $user_totalnewsdisplay, $user_ournews, $user_totaltestimonialdisplay, $user_ourtestimonial) {     $db = connectionstart();      $currentdatetime = date("y-m-d h:i:s", time());         $currentgmtdatetime = gmdate("y-m-d h:i:s", time() - (5 * 60 * 60));     $sql = "select * user_options ";     $result = mysql_evaluate($db, $sql, 0);     $columns = array(         "name" => 'slider'             , "value" => $user_slider         ,"name" => 'welcomebox'             , "value" => $user_welcomebox         ,"name" => 'servicebox'             , "value" => $user_servicebox         ,"name" => 'postbox'             , "value" => $user_postbox         ,"name" => 'testimonials'             , "value" => $user_testimonials         ,"name" => 'welcomemessage'             , "value" => $user_welcomemessage         ,"name" => 'welcomededcription'             , "value" => $user_welcomededcription         ,"name" => 'welcomelink'             , "value" => $user_welcomelink         ,"name" => 'welcomelinktitle'             , "value" => $user_welcomelinktitle         ,"name" => 'servicetitle'             , "value" => $user_servicetitle         ,"name" => 'totalservicedisplay'             , "value" => $user_totalservicedisplay         ,"name" => 'ourservice'             , "value" => $user_ourservice         ,"name" => 'blogtitle'             , "value" => $user_blogtitle         ,"name" => 'totalblogdisplay'             , "value" => $user_totalblogdisplay         ,"name" => 'ourblog'             , "value" => $user_ourblog         ,"name" => 'newstitle'             , "value" => $user_newstitle         ,"name" => 'totalnewsdisplay'             , "value" => $user_totalnewsdisplay         ,"name" => 'ournews'             , "value" => $user_ournews         ,"name" => 'totaltestimonialdisplay'             , "value" => $user_totaltestimonialdisplay         ,"name" => 'ourtestimonial'             , "value" => $user_ourtestimonial         , "entrydate" => $currentdatetime          );     if ($result != 0) {         $result = mysql_update($db, "user_options", $columns, "");         if ($result == true) {             $result = 'success';         }     } else {         $result = mysql_insert($db, "user_options", $columns, "");         if ($result == true) {             $result = 'success';         }     }     connectionclose($db);     return $result; } 

this code insert last value this

id          name             value  1          testimonials      5 

i want insert data this

id      name               value  1      slider               0  2      welcome box          1  3      welcome message      hi 

function update

     if (!function_exists('mysql_update')) {  function mysql_update($db, $table, $columns, $where = "") {     $sql = "update `" . $table . "` set";     $arry = array();     foreach ($columns $field => $value) {         array_push($arry, " `" . $field . "`='" . $value . "' ");     }     // implode keys of $array...     $sql .= implode(",", $arry);     if (isset($where) && $where != "") {         $sql .= " " . $where;     }     $result = mysql_query($sql, $db) or die(mysql_error());     return $result; } 

}

function insert

     function mysql_insert($db, $table, $columns) {     $sql = "insert `" . $table . "` ";     // implode keys of $array...     $sql .= " (`" . implode("`, `", array_keys($columns)) . "`)";     // implode values of $array...     $sql .= " values ('" . implode("', '", $columns) . "') ";      $result = mysql_query($sql, $db) or die(mysql_error());     return $result; } 

change $columns such becomes

$columns = array(             "slider" => $user_slider,             "welcomebox" => $user_welcomebox,             ...             "ourtestimonial" => $user_testimonial);  function mysql_insert($db, $table, $columns) {     $sql = "insert `" . $table . "` ";     $sql .= " (`" . implode("`, `", array_keys($columns)) . "`)";     $sql .= " values ('" . implode("', '", array_values($columns)) . "') ";      $result = mysql_query($sql, $db) or die(mysql_error());     return $result; } 

Comments