Php 如何将数组传递到数据库中

Php 如何将数组传递到数据库中,php,sql,arrays,insert,Php,Sql,Arrays,Insert,我试图将数组传递到数据库中,但无法正确执行。 我有以下db行 Country, number, Page, date 想在我的数据库里找到这样的东西吗 id Country number Page date 2 Sweden 5 cat 14th june 2015 United 10 ind 14th june 2015 states 58 con 14th june 2

我试图将数组传递到数据库中,但无法正确执行。 我有以下db行

Country, number, Page, date
想在我的数据库里找到这样的东西吗

id    Country  number   Page   date
2     Sweden   5        cat    14th june 2015
      United   10       ind    14th june 2015   
      states   58       con    14th june 2015    
      France   101      aces   14th june 2015      
      Germany  200      ind    14th june 2015
我在用这个

if(isset($_POST['submit'])){
$new_res = mysql_query("INSERT INTO `em-res_db` VALUES('','$Country','$number','$Page','$date')");  
                if ($new_res){
                    //continue
    }

我希望您了解我正在尝试做的事情

创建一个与数组长度相同的循环,并在循环中插入将数据插入数据库的代码

范例

for(i=0;i<=count(array)-1;i++){
if(isset($_POST['submit'])){
$new_res = mysql_query("INSERT INTO `em-res_db` VALUES('','$Country','$number','$Page','$date')");  
                if ($new_res){
                    //continue
    }
}

我想您必须使用不推荐的mysql扩展来循环POST1停止,转而使用PDO或mysqli。2了解并准备好陈述。3使用准备好的语句,并使用值数组执行它们。3b如果id是你的PK,并且是一个自动递增字段,那么不要插入一个空字符串作为值,只需指定你实际设置的字段,并让DB处理自动递增的内容。你的数据库连接在哪里?它产生了什么错误?我的连接mysql\u连接'localhost','root',;mysql_选择_数据库“我的数据库”;我在数据库中看到的只是数组