我用print_r()把数据以数组的形式读出来了,输出数据如下:
Array ( [[email protected]] => Array ( [email] => [email protected] [name] => cuiguangm [group] => ) [[email protected]] => Array ( [email] => [email protected] [name] => 悠悠 [group] => 常用联系人 ) [[email protected]] => Array ( [email] => [email protected] [name] => lesen [group] => ) [[email protected]] => Array ( [email] => [email protected] [name] => [email protected] [group] => ) ) 怎么把这些信息读到数据库中呢?只要email,name就可以。因为刚刚学,还不会,希望大家帮帮我。
Array ( [[email protected]] => Array ( [email] => [email protected] [name] => cuiguangm [group] => ) [[email protected]] => Array ( [email] => [email protected] [name] => 悠悠 [group] => 常用联系人 ) [[email protected]] => Array ( [email] => [email protected] [name] => lesen [group] => ) [[email protected]] => Array ( [email] => [email protected] [name] => [email protected] [group] => ) ) 怎么把这些信息读到数据库中呢?只要email,name就可以。因为刚刚学,还不会,希望大家帮帮我。
mysql_connect('地址', '数据库用户名', '数据库用户密码') or die('数据库连接失败');
//mysql_query('set names gbk');//设置数据库读取数据的编码
$arr = array();//假如$arr是你的那个数字
foreach($arr as $v){
$sql = 'inesrt into table_name(email, name) values("'.$v['email'].'", "'.$v['name'].'")';
//或者$sql = 'update table_name set email = "'.$v['email'].'" where xxx = xxx';
mysql_query($sql);
}
根据键读取取$v['email'] 然后mysql_query()
}