https://jumnuoy.blogspot.com/2013/06/function-insert-simple-array-with.htmlhow y can store in my BD Mysql this array:
Ok, let to go:
-Function for insert:
$data = array(
"id" => "1",
"title" => "This my test",
"by"=>"Socheat"
);
ID | TITLE | BY
---------------------------
1 This my test1 SOCHEAT
9 This my test1 SARET
Ok, let to go:
/*Table name*/
$table = "title";
/*Data array to insert*/
$data = array(
"id" => "1",
"title" => "This my test",
"by"=>"Socheat"
);
insert($table, $data);
-Function for insert:
function insert($table, $data)
{
$keys = array();
$values = array();
foreach($data as $key => $value)
{
$keys[] = $key;
$values[] = $value;
}
$check = mysql_query("INSERT INTO $table (".implode(',',$keys).") VALUES('" . implode("', '", $values) . "')");
}
how y can store in my BD Mysql this array:
$data = array(
"id" => "1",
"title" => "This my test",
"by"=>"Socheat"
);
ID | TITLE | BY
---------------------------
1 This my test1 SOCHEAT
9 This my test1 SARET
Ok, let to go:
/*Table name*/
$table = "title";
/*Data array to insert*/
$data = array(
"id" => "1",
"title" => "This my test",
"by"=>"Socheat"
);
insert($table, $data);
-Function for insert:
function insert($table, $data)
{
$keys = array();
$values = array();
foreach($data as $key => $value)
{
$keys[] = $key;
$values[] = $value;
}
$check = mysql_query("INSERT INTO $table (".implode(',',$keys).") VALUES('" . implode("', '", $values) . "')");
}
code
How to
MySQL
PHP
0 comments:
Post a Comment