我已经解码了Json,现在想要在数据库中提交,
如何在条件何处使用此查询?
if(is_array($arr)){
$sql = "INSERT INTO wp_posts (post_title, post_type) values ";
$valuesArr = array();
foreach($arr as $row){
$email = mysql_real_escape_string( $row['property_name'] );
$post = mysql_real_escape_string( $row['post_type'] );
$valuesArr[] = "('$email', '$post')";
}
$sql .= implode(',', $valuesArr);
mysql_query($sql) or exit(mysql_error());
}
答案 0 :(得分:0)
if(is_array($arr)){
$valuesArr = array();
foreach($arr as $row){
$email = mysql_real_escape_string( $row['property_name'] );
$post = mysql_real_escape_string( $row['post_type'] );
$sql = "update wp_posts set post_title='".$email."', post_type='".$post."' where X=Y";
mysql_query($sql) or exit(mysql_error());
}
}